Explorar el Código

Merge branch 'dev/v4.9.1_rjj' of qmx/jy into feature/v4.9.1

renjiaojiao hace 1 año
padre
commit
0e375875cb

+ 74 - 0
src/jfw/front/index.go

@@ -258,6 +258,8 @@ func (nIndex *NewIndex) NewIndex() error {
 	nIndex.T["hotBuyers"] = NewHotEnt(false, 5)
 	//供应商
 	nIndex.T["supplyEnt"] = GetBidInfoPublishEnt()
+	//行业分析简报
+	nIndex.T["industryReport"] = GetIndustryAnalysisReport()
 	//招投标攻略
 	nIndex.T["strategyList"] = GetStrategyList()
 	//剑鱼课堂
@@ -522,3 +524,75 @@ func GetImportBidding() []*hotKeyWord {
 	}
 	return res
 }
+
+func GetIndustryAnalysisReport() (data []map[string]interface{}) {
+	redidKey := "pcIndexIndustryReport"
+	redisArr, _ := redis.Get(RedisNameNew, redidKey).([]interface{})
+	if len(redisArr) > 0 {
+		data = common.ObjArrToMapArr(redisArr)
+		return
+	}
+	res, err := g.DB().Query(gctx.New(), `SELECT * FROM  jyseo_test.analysis_report  WHERE 1=1  ORDER BY show_time DESC  limit 4`)
+	if err != nil || res.IsEmpty() {
+		return nil
+	}
+	for _, v := range res.List() {
+		info := formatRow(v)
+		data = append(data, map[string]interface{}{
+			"url":      info.Url,
+			"area":     info.Area,
+			"detail":   info.Detail,
+			"keyword":  info.Keyword,
+			"industry": info.Industry,
+			"title":    info.Title,
+		})
+	}
+	if len(data) > 0 {
+		redis.Put(RedisNameNew, redidKey, data, RedisTimeout)
+	}
+	return data
+}
+
+type InfoList struct {
+	Url      string
+	Area     string
+	Detail   string
+	Keyword  string
+	Industry string
+	Title    string
+}
+
+func formatRow(row map[string]interface{}, isDetail ...bool) *InfoList {
+	bl := &InfoList{
+		Url:  fmt.Sprintf("/hybg/%s.html", gconv.String(row["id"])),
+		Area: gconv.String(row["area"]),
+		//Detail:   gconv.String(row["desc"]),
+		Keyword:  gconv.String(row["key_word"]),
+		Industry: gconv.String(row["industry"]),
+	}
+	var title string //河南省建筑工程行业2024年第2周行业分
+	showTime, classify := time.Unix(gconv.Int64(row["show_time"]), 0), gconv.Int(row["classify"])
+	var finalImages []string
+	for _, imgUrl := range gconv.Strings(row["imags"]) {
+		finalImages = append(finalImages, fmt.Sprintf("%s%s", g.Cfg().MustGet(context.Background(), "analysisReport.images.requestPrefix").String(), imgUrl))
+	}
+	expandMap := map[string]interface{}{
+		"classify": classify,
+		"images":   finalImages,
+	}
+	switch classify { //1周报 2月报
+	case 1: //1周报
+		year, week := showTime.ISOWeek()
+		expandMap["year"], expandMap["date"] = year, week
+		title = fmt.Sprintf("%s%s%d年第%d周行业分析", common.If(bl.Area == "", "全国", bl.Area), bl.Industry, year, week)
+	case 2: //2月报
+		year, month := showTime.Year(), int(showTime.Month())
+		expandMap["year"], expandMap["date"] = year, month
+		title = fmt.Sprintf("%s%s%d年%d月行业分析", common.If(bl.Area == "", "全国", bl.Area), bl.Industry, year, month)
+	}
+	bl.Title = title
+	if len(isDetail) > 0 {
+		bl.Detail = fmt.Sprintf(gconv.String(row["content"]), gconv.Interfaces(finalImages)...)
+	}
+	return bl
+}

+ 4 - 2
src/web/templates/pc/template/index/data-service-module.html

@@ -74,13 +74,15 @@
         </footer>
         <header class="hot-industry-chart-header industry-report-header">
           <h3 class="title-left-line">行业分析简报</h3>
-          <a href="#" target="_blank">查看更多</a>
+          <a href="/hybg/" target="_blank">查看更多</a>
         </header>
         <main class="industry-report-main">
           <ul>
+            {{range $v := .T.industryReport}}
             <li>
-              <a href="#" title="" target="_blank">上海对外经贸大学智慧教室改造项目工程上海对外经贸大学智程上海对外经贸大学</a>
+              <a href="{{$v.url}}" title="" target="_blank">{{$v.title}}</a>
             </li>
+            {{end}}
           </ul>
         </main>
       </section>