|
@@ -155,23 +155,29 @@ func GetReportById(reportId int, login bool, userId int) (report *reportService.
|
|
|
reportInfo, err = reportService.GetReportById(reportId)
|
|
|
if err != nil {
|
|
|
logger.Error("获取研报失败:%v", err)
|
|
|
- err = exception.New(exception.GetReportFailed)
|
|
|
+ err = exception.NewWithException(exception.GetReportFailed, err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ mappingRiskLevel, userRiskStatus, err := user.CheckUserRiskMatchStatus(userId)
|
|
|
+ if err != nil {
|
|
|
+ logger.Error("获取研报失败:%v", err)
|
|
|
+ err = exception.NewWithException(exception.GetReportFailed, err.Error())
|
|
|
return
|
|
|
}
|
|
|
- return DealReportInfo(&reportInfo, login, userId)
|
|
|
+ return DealReportInfo(&reportInfo, login, userId, mappingRiskLevel, userRiskStatus)
|
|
|
}
|
|
|
|
|
|
-func GetTotalPageCountByPermissionIds(permissionIds []int, isLogin bool, userId int) (total int64, latestId int64, ids map[string][]int, disCardIds []int) {
|
|
|
+func GetTotalPageCountByPermissionIds(permissionIds []int, isLogin bool, userId int) (total int64, latestId int64, ids map[string][]int, disCardIds []int, mappingRiskLevel, userRiskStatus string) {
|
|
|
return getCount(permissionIds, isLogin, userId)
|
|
|
}
|
|
|
|
|
|
// ParseRiskLevel 解析风险等级字符串,并返回数字部分
|
|
|
|
|
|
-func SearchReportList(key string, Ids []int, pageInfo page.PageInfo, isLogin bool, userId int) (list []reportService.ReportDTO, err error) {
|
|
|
+func SearchReportList(key string, Ids []int, pageInfo page.PageInfo, isLogin bool, userId int, mappingRiskLevel, userRiskStatus string) (list []reportService.ReportDTO, err error) {
|
|
|
offset := page.StartIndex(pageInfo.Current, pageInfo.PageSize)
|
|
|
var reports []reportService.ReportDTO
|
|
|
reports, err = reportService.SearchReportList(key, Ids, offset, pageInfo.PageSize, pageInfo.LatestId)
|
|
|
- list, err = dealReportInfo(reports, isLogin, userId)
|
|
|
+ list, err = dealReportInfo(reports, isLogin, userId, mappingRiskLevel, userRiskStatus)
|
|
|
if err != nil {
|
|
|
err = exception.New(exception.SearchReportPageFailed)
|
|
|
}
|
|
@@ -185,12 +191,12 @@ func SearchReportProduct(key string, docIds []int) (list []reportService.ReportD
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
-func RangeSearchByAnalyst(analystName string, userId int) (total int64, latestId int64, ids []int) {
|
|
|
+func RangeSearchByAnalyst(analystName string, userId int) (total int64, latestId int64, ids []int, mappingRiskLevel, userRiskStatus string) {
|
|
|
return getCountByAnalyst(nil, true, userId, analystName)
|
|
|
}
|
|
|
-func RangeSearch(key string, isLogin bool, userId int) (total int64, latestId int64, reportIds []int, discardIds []int, err error) {
|
|
|
+func RangeSearch(key string, isLogin bool, userId int) (total int64, latestId int64, reportIds []int, discardIds []int, mappingRiskLevel, userRiskStatus string, err error) {
|
|
|
var orgIds map[string][]int
|
|
|
- _, latestId, orgIds, discardIds = getCount(nil, isLogin, userId)
|
|
|
+ _, latestId, orgIds, discardIds, mappingRiskLevel, userRiskStatus = getCount(nil, isLogin, userId)
|
|
|
reportIds, err = GetReportByIdListByOrgIds(orgIds)
|
|
|
if err != nil {
|
|
|
logger.Error("获取报告ID列表失败:%v", err)
|
|
@@ -200,13 +206,13 @@ func RangeSearch(key string, isLogin bool, userId int) (total int64, latestId in
|
|
|
total = reportService.SearchMaxReportIdWithRange(key, reportIds)
|
|
|
return
|
|
|
}
|
|
|
-func dealReportInfo(list []reportService.ReportDTO, isLogin bool, userId int) (resultList []reportService.ReportDTO, err error) {
|
|
|
+func dealReportInfo(list []reportService.ReportDTO, isLogin bool, userId int, mappingRiskLevel, userRiskStatus string) (resultList []reportService.ReportDTO, err error) {
|
|
|
var wg sync.WaitGroup
|
|
|
wg.Add(len(list))
|
|
|
for i := 0; i < len(list); i++ {
|
|
|
go func(report *reportService.ReportDTO) {
|
|
|
defer wg.Done()
|
|
|
- report, err = DealReportInfo(report, isLogin, userId)
|
|
|
+ report, err = DealReportInfo(report, isLogin, userId, mappingRiskLevel, userRiskStatus)
|
|
|
if err != nil {
|
|
|
logger.Error("处理报告信息失败:%v", err)
|
|
|
}
|
|
@@ -217,7 +223,7 @@ func dealReportInfo(list []reportService.ReportDTO, isLogin bool, userId int) (r
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func DealReportInfo(report *reportService.ReportDTO, isLogin bool, userId int) (resultReport *reportService.ReportDTO, err error) {
|
|
|
+func DealReportInfo(report *reportService.ReportDTO, isLogin bool, userId int, mappingRiskLevel, userRiskStatus string) (resultReport *reportService.ReportDTO, err error) {
|
|
|
report.Login = isLogin
|
|
|
report.Permissions, report.PermissionNames = GetReportPermissionNames(report.OrgId, report.Source)
|
|
|
var permissions []permissionService.PermissionDTO
|
|
@@ -307,43 +313,50 @@ func DealReportInfo(report *reportService.ReportDTO, isLogin bool, userId int) (
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ }
|
|
|
+ if userRiskStatus != user.RiskValid {
|
|
|
+ if userRiskStatus == user.RiskUnTest {
|
|
|
+ report.RiskLevelStatus = RiskLevelUnTest
|
|
|
+ }
|
|
|
+ if userRiskStatus == user.RiskExpired {
|
|
|
+ report.RiskLevelStatus = RiskLevelExpired
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ report.RiskLevelStatus = RiskLevelUnMatch
|
|
|
+ if mappingRiskLevel != "" {
|
|
|
+ mappingRiskNum, parseErr := config.ParseRiskLevel(mappingRiskLevel)
|
|
|
+ if parseErr != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var rpRiskNum int
|
|
|
+ rpRiskNum, parseErr = config.ParseRiskLevel(report.RiskLevel)
|
|
|
+ if parseErr != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if rpRiskNum <= mappingRiskNum {
|
|
|
+ report.RiskLevelStatus = RiskLevelMatch
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- //report.RiskLevelStatus = RiskLevelUnMatch
|
|
|
- //if mappingRiskLevel != "" {
|
|
|
- // mappingRiskNum, parseErr := config.ParseRiskLevel(mappingRiskLevel)
|
|
|
- // if parseErr != nil {
|
|
|
- // return
|
|
|
- // }
|
|
|
- // var rpRiskNum int
|
|
|
- // rpRiskNum, parseErr = config.ParseRiskLevel(media.RiskLevel)
|
|
|
- // if parseErr != nil {
|
|
|
- // return
|
|
|
- // }
|
|
|
- // if rpRiskNum <= mappingRiskNum {
|
|
|
- // report.RiskLevelStatus = RiskLevelMatch
|
|
|
- // }
|
|
|
- //}
|
|
|
- //resultMedia = media
|
|
|
- //return
|
|
|
+
|
|
|
resultReport = report
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetReportPage 分页获取报告列表
|
|
|
-func GetReportPage(pageInfo page.PageInfo, orgIds map[string][]int, discardIds []int, isLogin bool, userId int) (reports []reportService.ReportDTO, err error) {
|
|
|
+func GetReportPage(pageInfo page.PageInfo, orgIds map[string][]int, discardIds []int, isLogin bool, userId int, mappingRiskLevel, userRiskStatus string) (reports []reportService.ReportDTO, err error) {
|
|
|
var list []reportService.ReportDTO
|
|
|
list, err = reportService.GetReportPageByOrgIds(pageInfo, orgIds, discardIds)
|
|
|
- reports, err = dealReportInfo(list, isLogin, userId)
|
|
|
+ reports, err = dealReportInfo(list, isLogin, userId, mappingRiskLevel, userRiskStatus)
|
|
|
if err != nil {
|
|
|
err = exception.New(exception.QueryReportPageFailed)
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
-func GetReportPageByAnalyst(pageInfo page.PageInfo, analyst string, reportIds []int, templateUserId int) (list []reportService.ReportDTO, err error) {
|
|
|
+func GetReportPageByAnalyst(pageInfo page.PageInfo, analyst string, reportIds []int, templateUserId int, mappingRiskLevel, userRiskStatus string) (list []reportService.ReportDTO, err error) {
|
|
|
list, err = reportService.GetReportPageByAnalyst(pageInfo, analyst, reportIds)
|
|
|
- list, err = dealReportInfo(list, true, templateUserId)
|
|
|
+ list, err = dealReportInfo(list, true, templateUserId, mappingRiskLevel, userRiskStatus)
|
|
|
if err != nil {
|
|
|
err = exception.New(exception.QueryReportPageFailed)
|
|
|
}
|
|
@@ -359,7 +372,7 @@ func CountReport(count RecordCount) (traceId string, err error) {
|
|
|
dto.SourceTitle = report.Title
|
|
|
return userService.CountReport(dto)
|
|
|
}
|
|
|
-func GetRandedReportByWeeklyHot(limit int, isLogin bool, userId int, pdRiskLevel string) (reports []HotRankedReport, err error) {
|
|
|
+func GetRandedReportByWeeklyHot(limit int, isLogin bool, userId int, mappingRiskLevel string, userRiskStatus string) (reports []HotRankedReport, err error) {
|
|
|
end := time.Now()
|
|
|
begin := date.GetBeginOfTheWeek(end, time.Monday)
|
|
|
hotReports := userService.GetHotReports(begin.Format(time.DateOnly), end.Format(time.DateOnly), limit)
|
|
@@ -375,21 +388,21 @@ func GetRandedReportByWeeklyHot(limit int, isLogin bool, userId int, pdRiskLevel
|
|
|
err = exception.New(exception.GetHotRandListFailed)
|
|
|
return
|
|
|
}
|
|
|
- dtoList, err = dealReportInfo(dtoList, isLogin, userId)
|
|
|
+ dtoList, err = dealReportInfo(dtoList, isLogin, userId, mappingRiskLevel, userRiskStatus)
|
|
|
if err != nil {
|
|
|
logger.Error("获取本周最热研报列表失败:%v", err)
|
|
|
err = exception.New(exception.GetHotRandListFailed)
|
|
|
return
|
|
|
}
|
|
|
var filterList []reportService.ReportDTO
|
|
|
- if pdRiskLevel != "" {
|
|
|
+ if mappingRiskLevel != "" {
|
|
|
for _, report := range dtoList {
|
|
|
pdRiskNum, paresErr := config.ParseRiskLevel(report.RiskLevel)
|
|
|
if paresErr != nil {
|
|
|
logger.Error("解析风险等级失败:%v", err)
|
|
|
continue
|
|
|
}
|
|
|
- reRiskNum, paresErr := config.ParseRiskLevel(pdRiskLevel)
|
|
|
+ reRiskNum, paresErr := config.ParseRiskLevel(mappingRiskLevel)
|
|
|
if paresErr != nil {
|
|
|
logger.Error("解析风险等级失败:%v", err)
|
|
|
continue
|
|
@@ -423,7 +436,7 @@ func GetRandedReportByWeeklyHot(limit int, isLogin bool, userId int, pdRiskLevel
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func GetRandedReportByPublishTimeWeekly(limit int, week bool, isLogin bool, userId int, pdRiskLevel string) (reports []PublishRankedReport, err error) {
|
|
|
+func GetRandedReportByPublishTimeWeekly(limit int, week bool, isLogin bool, userId int, mappingRiskLevel, userRiskStatus string) (reports []PublishRankedReport, err error) {
|
|
|
dtoList, err := reportService.GetListOrderByConditionWeekly(week, "published_time", limit, reportService.DESC)
|
|
|
if err != nil {
|
|
|
logger.Error("获取最新发布的研报列表失败:%v", err)
|
|
@@ -431,20 +444,20 @@ func GetRandedReportByPublishTimeWeekly(limit int, week bool, isLogin bool, user
|
|
|
return
|
|
|
}
|
|
|
var filterList []reportService.ReportDTO
|
|
|
- dtoList, err = dealReportInfo(dtoList, isLogin, userId)
|
|
|
+ dtoList, err = dealReportInfo(dtoList, isLogin, userId, mappingRiskLevel, userRiskStatus)
|
|
|
if err != nil {
|
|
|
logger.Error("获取最新发布的研报列表失败:%v", err)
|
|
|
err = exception.New(exception.GetPublishedRandListFailed)
|
|
|
return
|
|
|
}
|
|
|
- if pdRiskLevel != "" {
|
|
|
+ if mappingRiskLevel != "" {
|
|
|
for _, report := range dtoList {
|
|
|
pdRiskNum, paresErr := config.ParseRiskLevel(report.RiskLevel)
|
|
|
if paresErr != nil {
|
|
|
logger.Error("解析风险等级失败:%v", err)
|
|
|
continue
|
|
|
}
|
|
|
- reRiskNum, paresErr := config.ParseRiskLevel(pdRiskLevel)
|
|
|
+ reRiskNum, paresErr := config.ParseRiskLevel(mappingRiskLevel)
|
|
|
if paresErr != nil {
|
|
|
logger.Error("解析风险等级失败:%v", err)
|
|
|
continue
|
|
@@ -584,12 +597,12 @@ func GetReportByIdListByOrgIds(orgIds map[string][]int) (ids []int, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func RangePermissionIds(isLogin bool, userId int) (filterPermissionIds []int, riskLevel string, err error) {
|
|
|
+func RangePermissionIds(isLogin bool, userId int) (filterPermissionIds []int, riskLevel string, userRiskStatus string, err error) {
|
|
|
return user.GetRiskLevelPermissionList(nil, isLogin, userId)
|
|
|
}
|
|
|
|
|
|
-func getCount(permissionIds []int, isLogin bool, userId int) (total int64, latestId int64, ids map[string][]int, discardIds []int) {
|
|
|
- filterPermissionIds, _, err := user.GetRiskLevelPermissionList(permissionIds, isLogin, userId)
|
|
|
+func getCount(permissionIds []int, isLogin bool, userId int) (total int64, latestId int64, ids map[string][]int, discardIds []int, mappingRiskLevel, userRiskStatus string) {
|
|
|
+ filterPermissionIds, mappingRiskLevel, userRiskStatus, err := user.GetRiskLevelPermissionList(permissionIds, isLogin, userId)
|
|
|
if err != nil {
|
|
|
logger.Error("获取过滤品种信息失败:%v", err)
|
|
|
return
|
|
@@ -598,16 +611,18 @@ func getCount(permissionIds []int, isLogin bool, userId int) (total int64, lates
|
|
|
logger.Warn("不存在设置风险等级的品种信息")
|
|
|
return
|
|
|
}
|
|
|
- return reportService.GetTotalPageCountByPermissionIds(filterPermissionIds)
|
|
|
+ total, latestId, ids, discardIds = reportService.GetTotalPageCountByPermissionIds(filterPermissionIds)
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
-func getCountByAnalyst(permissionIds []int, isLogin bool, userId int, analystName string) (total int64, latestId int64, ids []int) {
|
|
|
- filterPermissionIds, _, err := user.GetRiskLevelPermissionList(permissionIds, isLogin, userId)
|
|
|
+func getCountByAnalyst(permissionIds []int, isLogin bool, userId int, analystName string) (total int64, latestId int64, ids []int, mappingRiskLevel, userRiskStatus string) {
|
|
|
+ filterPermissionIds, mappingRiskLevel, userRiskStatus, err := user.GetRiskLevelPermissionList(permissionIds, isLogin, userId)
|
|
|
if err != nil {
|
|
|
logger.Error("校验用户风险等级失败:%v", err)
|
|
|
return
|
|
|
}
|
|
|
- return reportService.GetTotalPageCountByAnalyst(analystName, filterPermissionIds)
|
|
|
+ total, latestId, ids = reportService.GetTotalPageCountByAnalyst(analystName, filterPermissionIds)
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
func CountPermissionWeight(ids []int) (permissionMap map[int]int) {
|