|
@@ -5,6 +5,7 @@ import (
|
|
"fmt"
|
|
"fmt"
|
|
"hongze/hongze_cygx/models"
|
|
"hongze/hongze_cygx/models"
|
|
"hongze/hongze_cygx/utils"
|
|
"hongze/hongze_cygx/utils"
|
|
|
|
+ "strings"
|
|
)
|
|
)
|
|
|
|
|
|
// GetArticleGroupSubjectMapByIndustrialManagementId 通过文章ID,产业;获取文章所关联的标的
|
|
// GetArticleGroupSubjectMapByIndustrialManagementId 通过文章ID,产业;获取文章所关联的标的
|
|
@@ -19,27 +20,63 @@ func GetArticleGroupSubjectMapByIndustrialManagementId(articleIds []int, industr
|
|
go utils.SendAlarmMsg(fmt.Sprint("通过文章ID,产业;获取文章所关联的标的失败 ,GetArticleGroupSubjectMapByIndustrialManagementId err"+err.Error(), "articleIds:", articleIds), 2)
|
|
go utils.SendAlarmMsg(fmt.Sprint("通过文章ID,产业;获取文章所关联的标的失败 ,GetArticleGroupSubjectMapByIndustrialManagementId err"+err.Error(), "articleIds:", articleIds), 2)
|
|
}
|
|
}
|
|
}()
|
|
}()
|
|
|
|
+ mapSubject := make(map[string]int)
|
|
|
|
+ listSub, e := models.GetcygxIndustrialSubject(industrialManagementId)
|
|
|
|
+ if e != nil {
|
|
|
|
+ err = errors.New("GetcygxIndustrialSubject, Err: " + e.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ for _, v := range listSub {
|
|
|
|
+ mapSubject[v.SubjectName] = v.IndustrialSubjectId
|
|
|
|
+ }
|
|
|
|
+
|
|
var condition string
|
|
var condition string
|
|
var pars []interface{}
|
|
var pars []interface{}
|
|
- condition = ` AND g.article_id IN (` + utils.GetOrmInReplace(len(articleIds)) + `) AND s.industrial_management_id = ? `
|
|
|
|
- pars = append(pars, articleIds, industrialManagementId)
|
|
|
|
- list, e := models.GetArticleGroupSubjectList(pars, condition)
|
|
|
|
|
|
+ condition += ` AND article_id IN (` + utils.GetOrmInReplace(len(articleIds)) + `) `
|
|
|
|
+ pars = append(pars, articleIds)
|
|
|
|
+ articleList, e := models.GetArticleList(condition, pars)
|
|
if e != nil {
|
|
if e != nil {
|
|
- err = errors.New("GetArticleGroupSubjectList " + e.Error())
|
|
|
|
|
|
+ err = errors.New("GetArticleList, Err: " + e.Error())
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- listMap := make(map[int][]*models.CygxIndustrialSubject, 0)
|
|
|
|
|
|
|
|
- if len(list) > 0 {
|
|
|
|
- for _, v := range list {
|
|
|
|
|
|
+ listMap := make(map[int][]*models.CygxIndustrialSubject, 0)
|
|
|
|
+ for _, v := range articleList {
|
|
|
|
+ sliceSubjects := strings.Split(v.Stock, "/")
|
|
|
|
+ for _, vSubject := range sliceSubjects {
|
|
|
|
+ sliceKuohao := strings.Split(vSubject, "(") //过滤括号
|
|
|
|
+ sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
|
|
|
|
+ subject := sliceXiahuaxian[0]
|
|
|
|
+ if mapSubject[subject] == 0 {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
item := models.CygxIndustrialSubject{
|
|
item := models.CygxIndustrialSubject{
|
|
- IndustrialSubjectId: v.IndustrialSubjectId,
|
|
|
|
- IndustrialManagementId: v.IndustrialManagementId,
|
|
|
|
- SubjectName: v.SubjectName,
|
|
|
|
|
|
+ IndustrialSubjectId: mapSubject[subject],
|
|
|
|
+ IndustrialManagementId: industrialManagementId,
|
|
|
|
+ SubjectName: subject,
|
|
}
|
|
}
|
|
listMap[v.ArticleId] = append(listMap[v.ArticleId], &item)
|
|
listMap[v.ArticleId] = append(listMap[v.ArticleId], &item)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //condition = ` AND g.article_id IN (` + utils.GetOrmInReplace(len(articleIds)) + `) AND s.industrial_management_id = ? `
|
|
|
|
+ //pars = append(pars, articleIds, industrialManagementId)
|
|
|
|
+ //list, e := models.GetArticleGroupSubjectList(pars, condition)
|
|
|
|
+ //if e != nil {
|
|
|
|
+ // err = errors.New("GetArticleGroupSubjectList " + e.Error())
|
|
|
|
+ // return
|
|
|
|
+ //}
|
|
|
|
+ //
|
|
|
|
+ //if len(list) > 0 {
|
|
|
|
+ // for _, v := range list {
|
|
|
|
+ // item := models.CygxIndustrialSubject{
|
|
|
|
+ // IndustrialSubjectId: v.IndustrialSubjectId,
|
|
|
|
+ // IndustrialManagementId: v.IndustrialManagementId,
|
|
|
|
+ // SubjectName: v.SubjectName,
|
|
|
|
+ // }
|
|
|
|
+ // listMap[v.ArticleId] = append(listMap[v.ArticleId], &item)
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
mapResp = listMap
|
|
mapResp = listMap
|
|
return
|
|
return
|
|
}
|
|
}
|