|
@@ -4,6 +4,7 @@ import (
|
|
|
"encoding/json"
|
|
|
"eta_gn/eta_api/models"
|
|
|
"eta_gn/eta_api/models/system"
|
|
|
+ "eta_gn/eta_api/services"
|
|
|
"eta_gn/eta_api/services/ice_message"
|
|
|
"eta_gn/eta_api/utils"
|
|
|
"fmt"
|
|
@@ -277,6 +278,8 @@ func (c *ReportIceMessageController) IceMsgPush() {
|
|
|
var title, summary, content string
|
|
|
var reportInfo *models.Report
|
|
|
var pptInfo *models.PptV2
|
|
|
+ var classifyName string
|
|
|
+ var url string
|
|
|
// 根据类型判断
|
|
|
if classifyType == 1 {// 推送研报
|
|
|
if req.ReportId <= 0 {
|
|
@@ -308,8 +311,7 @@ func (c *ReportIceMessageController) IceMsgPush() {
|
|
|
sendClassifyId = reportInfo.ClassifyIdFirst
|
|
|
}
|
|
|
title = reportInfo.Title
|
|
|
- summary = reportInfo.Abstract
|
|
|
- content = reportInfo.Title
|
|
|
+ url = reportInfo.DetailPdfUrl
|
|
|
} else if classifyType == 2 {// 推送PPT
|
|
|
if req.PptId <= 0 {
|
|
|
br.Msg = "PPTID不能为空"
|
|
@@ -327,10 +329,22 @@ func (c *ReportIceMessageController) IceMsgPush() {
|
|
|
}
|
|
|
sendClassifyId = pptInfo.ClassifyId
|
|
|
title = pptInfo.Title
|
|
|
- summary = pptInfo.Abstract
|
|
|
- content = pptInfo.Title
|
|
|
+ url = pptInfo.PptxUrl
|
|
|
}
|
|
|
- //
|
|
|
+ // 获取分类名称
|
|
|
+ classify, err := models.GetClassifyById(sendClassifyId)
|
|
|
+ if err != nil {
|
|
|
+ if !utils.IsErrNoRow(err) {
|
|
|
+ br.Msg = "查询失败"
|
|
|
+ br.ErrMsg = "查询失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }else{
|
|
|
+ br.Msg = "分类不存在"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ classifyName = classify.ClassifyName
|
|
|
+
|
|
|
// 判断该分类是否设置了消息推送配置
|
|
|
configObj := new(models.ReportMessageConfig)
|
|
|
config, err := configObj.GetItemByClassifyId(sendClassifyId)
|
|
@@ -375,7 +389,7 @@ func (c *ReportIceMessageController) IceMsgPush() {
|
|
|
// 生成taskId
|
|
|
taskId := utils.MD5(fmt.Sprintf("%s_%s_%s_%s", req.ReportId, req.PptId, item.AdminId, time.Now().Format("20060102150405")))
|
|
|
|
|
|
- err = ice_message.PushIceMessage(title, summary, content, item.EmployeeId, taskId, req.ReportId, req.PptId)
|
|
|
+ err = ice_message.PushIceMessage(title, summary, content, item.EmployeeId, taskId, req.ReportId, req.PptId, url, classifyName)
|
|
|
if err != nil {
|
|
|
sendStatus = 2
|
|
|
}else{
|
|
@@ -437,4 +451,95 @@ func (c *ReportIceMessageController) IceMsgPush() {
|
|
|
br.ErrMsg = "推送失败,Err:" + err.Error()
|
|
|
br.Ret = 408
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+// ListClassify
|
|
|
+// @Title 获取分类列表
|
|
|
+// @Description 获取分类列表
|
|
|
+// @Param KeyWord query string true "检索关键词"
|
|
|
+// @Param ClassifyType query int false "分类类型:0-全部(默认);1-研报;2-PPT"
|
|
|
+// @Param Enabled query int false "启用状态:-1-全部(默认);0-禁用;1-启用"
|
|
|
+// @Success 200 {object} models.Classify
|
|
|
+// @router /ice_msg/classify [get]
|
|
|
+func (c *ReportIceMessageController) ListClassify() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ c.Data["json"] = br
|
|
|
+ c.ServeJSON()
|
|
|
+ }()
|
|
|
+
|
|
|
+ classifyNames := make([]string, 0)
|
|
|
+ classifyNames = append(classifyNames, utils.REPORT_ICE_MSG_CLASSIFY_NAMES...)
|
|
|
+
|
|
|
+
|
|
|
+ // 获取所有分类
|
|
|
+ originList, err := models.GetClassifyListByClassifyNameList(classifyNames)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //查找所有的父级分类
|
|
|
+ parentIds := make([]int, 0)
|
|
|
+ for _, v := range originList {
|
|
|
+ // 解析levelpath
|
|
|
+ levelPath := strings.Split(v.LevelPath, ",")
|
|
|
+ for _, i := range levelPath {
|
|
|
+ if i != "" {
|
|
|
+ parentId, _ := strconv.Atoi(i)
|
|
|
+ parentIds = append(parentIds, parentId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ originList, err = models.GetClassifyListByParentIdList(parentIds)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ list := originList
|
|
|
+ classifyIds := make([]int, 0)
|
|
|
+ for _, v := range list {
|
|
|
+ classifyIds = append(classifyIds, v.Id)
|
|
|
+ }
|
|
|
+ // 指定分类类型(上级中的分类类型可能与最下层的不一致,但是要把上级也一起取出来, 这需求...=_=!)'
|
|
|
+ reportMsgConfigMap := make(map[int][]int)
|
|
|
+ // 根据分类ID获取配置项
|
|
|
+ reportMsgObj := new(models.ReportMessageConfig)
|
|
|
+ configList, err := reportMsgObj.GetListByClassifyIdList(classifyIds)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range configList {
|
|
|
+ if v.NotifyUsers != "" {
|
|
|
+ notifyUsers := strings.Split(v.NotifyUsers, ",")
|
|
|
+ for _, user := range notifyUsers {
|
|
|
+ userInt, _ := strconv.Atoi(user)
|
|
|
+ reportMsgConfigMap[v.ClassifyId] = append(reportMsgConfigMap[v.ClassifyId], userInt)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, v := range list {
|
|
|
+ if iceMessageUsers, ok := reportMsgConfigMap[v.Id]; ok {
|
|
|
+ v.IceMsgUsers = iceMessageUsers
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 先将分类列表排序
|
|
|
+ services.SortClassifyListBySortAndCreateTime(list)
|
|
|
+ // 接着转换结构
|
|
|
+ list = services.GetClassifyListTreeRecursive(list, 0)
|
|
|
+ // 过滤掉没有子目录的分类
|
|
|
+ list = services.RecursiveFilterNoChildTreeClassify(list)
|
|
|
+
|
|
|
+ resp := new(models.ClassifyListResp)
|
|
|
+ resp.List = list
|
|
|
+ br.Data = resp
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
}
|