|
@@ -131,8 +131,76 @@ func GetGetReportById(reportId int) (ReportDTO ReportDTO, err error) {
|
|
|
func GetTotalPageCount() (total int64, latestId int64, err error) {
|
|
|
return reportDao.GetTotalPageCount()
|
|
|
}
|
|
|
-func GetTotalPageCountByAnalyst(analyst string) (total int64, latestId int64) {
|
|
|
- return reportDao.GetTotalPageCountByAnalyst(analyst)
|
|
|
+func GetTotalPageCountByAnalyst(analyst string, permissionIds []int) (total int64, latestId int64, ids []int) {
|
|
|
+ ids, err := reportDao.GetReportsByAnalyst(analyst)
|
|
|
+ if err != nil {
|
|
|
+ logger.Error("查询研究研报告列表id失败:%v", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //查询这些包含在列表中的权限的报告ids
|
|
|
+ htOrgIds, err := GetHTReportIdsByPermissionIds(permissionIds)
|
|
|
+ if err != nil {
|
|
|
+ logger.Error("品种筛选ht报告id失败:%v", err)
|
|
|
+ htOrgIds = []int{}
|
|
|
+ }
|
|
|
+ etaOrgIds, err := GetETAReportIdsByPermissionIds(permissionIds)
|
|
|
+ if err != nil {
|
|
|
+ logger.Error("品种筛选eta报告id失败:%v", err)
|
|
|
+ etaOrgIds = []int{}
|
|
|
+ }
|
|
|
+ if len(etaOrgIds) == 0 && len(htOrgIds) == 0 {
|
|
|
+ logger.Info("没有符合权限的研报")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ orgIds := make(map[string][]int, 2)
|
|
|
+ if len(etaOrgIds) == 0 {
|
|
|
+ orgIds["ETA"] = []int{}
|
|
|
+ } else {
|
|
|
+ orgIds["ETA"] = etaOrgIds
|
|
|
+ }
|
|
|
+ if len(htOrgIds) == 0 {
|
|
|
+ orgIds["HT"] = []int{}
|
|
|
+ } else {
|
|
|
+ orgIds["HT"] = htOrgIds
|
|
|
+ }
|
|
|
+ permitReportIds, err := reportDao.GetReportIdListByOrgIds(orgIds)
|
|
|
+ if err != nil {
|
|
|
+ logger.Error("根据原始报告id获取报告id列表失败:%v", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var filterReportIds []int
|
|
|
+ for _, id := range ids {
|
|
|
+ for _, permitReportId := range permitReportIds {
|
|
|
+ if id == permitReportId {
|
|
|
+ filterReportIds = append(filterReportIds, id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(filterReportIds) == 0 {
|
|
|
+ logger.Info("没有符合权限的研究员研报")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ ids = filterReportIds
|
|
|
+ total = int64(len(filterReportIds))
|
|
|
+ latestId = int64(findMax(filterReportIds))
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// findMaxWithError 函数用于找到整型数组中的最大值,并返回错误信息
|
|
|
+func findMax(nums []int) (max int) {
|
|
|
+ if len(nums) == 0 {
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ // 初始化最大值为数组的第一个元素
|
|
|
+ max = nums[0]
|
|
|
+
|
|
|
+ // 遍历数组,找到最大值
|
|
|
+ for _, num := range nums {
|
|
|
+ if num > max {
|
|
|
+ max = num
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
}
|
|
|
func SearchMaxReportId(key string) (total int64, reportId int64) {
|
|
|
sort := []string{"reportId:desc"}
|
|
@@ -196,9 +264,9 @@ func SearchReportList(key string, ids []int, from int, size int, max int64) (rep
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
-func GetReportPageByAnalyst(pageInfo page.PageInfo, analyst string) (list []ReportDTO, err error) {
|
|
|
+func GetReportPageByAnalyst(pageInfo page.PageInfo, analyst string, reportIds []int) (list []ReportDTO, err error) {
|
|
|
offset := page.StartIndex(pageInfo.Current, pageInfo.PageSize)
|
|
|
- reports, err := reportDao.GetReportPageByAnalyst(pageInfo.LatestId, pageInfo.PageSize, offset, analyst)
|
|
|
+ reports, err := reportDao.GetReportPageByAnalyst(pageInfo.LatestId, pageInfo.PageSize, offset, analyst, reportIds)
|
|
|
if err != nil {
|
|
|
logger.Error("分页查询报告列表失败:%v", err)
|
|
|
return
|