|
@@ -10,9 +10,11 @@ import (
|
|
|
"hongze/hongze_open_api/models/tables/chart_permission_search_key_word_mapping"
|
|
|
"hongze/hongze_open_api/models/tables/company_product"
|
|
|
"hongze/hongze_open_api/models/tables/company_report_permission"
|
|
|
+ "hongze/hongze_open_api/models/tables/daily_base_column"
|
|
|
"hongze/hongze_open_api/models/tables/rddp/classify"
|
|
|
"hongze/hongze_open_api/models/tables/rddp/report"
|
|
|
"hongze/hongze_open_api/models/tables/rddp/report_chapter"
|
|
|
+ "hongze/hongze_open_api/models/tables/rddp/report_chapter_ticker"
|
|
|
"hongze/hongze_open_api/models/tables/report_chapter_type"
|
|
|
"hongze/hongze_open_api/models/tables/wx_user"
|
|
|
"hongze/hongze_open_api/services/company"
|
|
@@ -525,11 +527,29 @@ func GetChapterDetail(mobile string, reportChapterId int) (reportChapterDetail r
|
|
|
reportChapterItem.ContentSub = html.UnescapeString(reportChapter.ContentSub)
|
|
|
}
|
|
|
|
|
|
+ //请求指标数据的参数
|
|
|
+ tickerDataParams := ``
|
|
|
+ {
|
|
|
+ nonceStr := common.GetRandString(10)
|
|
|
+ timeUnix := strconv.FormatInt(time.Now().Unix(), 10)
|
|
|
+ postData := make(map[string]string)
|
|
|
+ reportChapterIdStr := strconv.Itoa(reportChapterId)
|
|
|
+ parameter := "report_chapter_id=" + reportChapterIdStr + "&nonce_str=" + nonceStr + "×tamp=" + timeUnix
|
|
|
+ postData["mobile"] = encryptMobile
|
|
|
+ postData["report_chapter_id"] = reportChapterIdStr
|
|
|
+ postData["appid"] = utils.ReportAppid
|
|
|
+ postData["nonce_str"] = nonceStr
|
|
|
+ postData["timestamp"] = timeUnix
|
|
|
+ sign := utils.GetSign(postData)
|
|
|
+ tickerDataParams = parameter + "&sign=" + sign
|
|
|
+ }
|
|
|
+
|
|
|
reportChapterDetail = reportResp.ReportChapterDetail{
|
|
|
ReportChapterItem: reportChapterItem,
|
|
|
ReportChapterMenuList: chapterMenu,
|
|
|
AuthOk: authOk,
|
|
|
PermissionCheck: permissionCheckInfo,
|
|
|
+ TickerDataParams: tickerDataParams,
|
|
|
//LikeNum: 0,
|
|
|
//LikeEnabled: 0,
|
|
|
}
|
|
@@ -648,3 +668,87 @@ func CheckReportPermission(userInfo *wx_user.WxUser, reportId int, productAuthOk
|
|
|
authOk, permissionCheckInfo, _, err = company.GetCheckPermission(userInfo.CompanyId, int(userInfo.UserId), permissionIds)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+// GetTickerData 获取指标数据
|
|
|
+func GetTickerData(reportChapterId int) (ret reportResp.TickerData, err error, errMsg string) {
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ utils.FileLog.Critical(fmt.Sprintf("GetTickerData: err:%s, errMsg:%s", err.Error(), errMsg))
|
|
|
+ }
|
|
|
+ }()
|
|
|
+
|
|
|
+ //查询章节类型
|
|
|
+ chapter, err := report_chapter.GetTypeIdById(reportChapterId)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = err.Error()
|
|
|
+ err = errors.New("查询章节失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if chapter.ReportChapterId == 0 {
|
|
|
+ err = errors.New("章节不存在或者未发布")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ tickers, err := report_chapter_ticker.GetTickerByChapterId(reportChapterId)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = err.Error()
|
|
|
+ err = errors.New("查询章节指标失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var list []reportResp.TickerDataItem
|
|
|
+ if len(tickers) > 0 {
|
|
|
+ var tickerNames []string
|
|
|
+ for _, v := range tickers {
|
|
|
+ tickerNames = append(tickerNames, v.Ticker)
|
|
|
+ }
|
|
|
+ var dataList []*daily_base_column.TickerDataItem
|
|
|
+ if chapter.TypeId == 17 {
|
|
|
+ dataList, err = daily_base_column.GetDataByBaseColumnTickers17(tickerNames)
|
|
|
+ } else {
|
|
|
+ dataList, err = daily_base_column.GetDataByBaseColumnTickers(tickerNames)
|
|
|
+ }
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ errMsg = err.Error()
|
|
|
+ err = errors.New("查询指标数据失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ chapterTypeInfo, tErr := report_chapter_type.GetTickerTitleByTypeId(chapter.TypeId)
|
|
|
+ if tErr != nil {
|
|
|
+ errMsg = tErr.Error()
|
|
|
+ err = errors.New("查询章节类型失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(dataList) >= 0 {
|
|
|
+ for _, v := range dataList {
|
|
|
+ temp := reportResp.TickerDataItem{
|
|
|
+ Date: v.Date,
|
|
|
+ Ticker: v.Ticker,
|
|
|
+ BaseColumnName: v.BaseColumnName,
|
|
|
+ }
|
|
|
+ temp.TickerValue, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", v.TickerValue), 2)
|
|
|
+ temp.LastValue, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", v.LastValue), 2)
|
|
|
+ temp.MmValue, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", v.MmValue), 2)
|
|
|
+ temp.DdValue, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", v.DdValue), 2)
|
|
|
+ temp.WwValue, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", v.WwValue), 2)
|
|
|
+
|
|
|
+ list = append(list, temp)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ tickerTitle := reportResp.TickerTitleData{
|
|
|
+ TickerTitle: chapterTypeInfo.TickerTitle,
|
|
|
+ ReportChapterTypeId: int(chapterTypeInfo.ReportChapterTypeId),
|
|
|
+ ReportChapterTypeName: chapterTypeInfo.ReportChapterTypeName,
|
|
|
+ DataTableImage: fmt.Sprintf("http://hongze.oss-cn-shanghai.aliyuncs.com/data_table/%s.png", chapterTypeInfo.ReportChapterTypeKey),
|
|
|
+ }
|
|
|
+
|
|
|
+ ret = reportResp.TickerData{
|
|
|
+ List: list,
|
|
|
+ TickerTitle: tickerTitle,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|