|
@@ -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
|
|
|
+}
|