123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720 |
- package front
- import (
- "app.yhyue.com/moapp/jybase/common"
- util "app.yhyue.com/moapp/jybase/common"
- "app.yhyue.com/moapp/jybase/encrypt"
- "app.yhyue.com/moapp/jybase/go-xweb/xweb"
- "app.yhyue.com/moapp/jybase/redis"
- "app.yhyue.com/moapp/jypkg/public"
- "context"
- "encoding/json"
- "fmt"
- "github.com/gogf/gf/v2/frame/g"
- "github.com/gogf/gf/v2/os/gctx"
- "github.com/gogf/gf/v2/util/gconv"
- "jy/src/jfw/config"
- "jy/src/jfw/jyutil"
- "jy/src/jfw/site/jySchool"
- "log"
- "math/rand"
- "regexp"
- "strings"
- "time"
- )
- type NewIndex struct {
- *xweb.Action
- newIndex xweb.Mapper `xweb:"/"` //首页改版
- routerRelay xweb.Mapper `xweb:"/front/routerRelay/(.*)"` //企业服务中转
- appDownload xweb.Mapper `xweb:"/front/appDownload"` //新app下载页面
- }
- var (
- RedisTimeout = 2 * 3600
- routerRelayMap map[string]map[bool]string
- BiddingTypeUrl = map[int]string{
- 1: "/list/stype/ZBYG.html",
- 2: "/list/stype/ZBJG.html",
- 5: "/list/stype/CGYX.html",
- 6: "/list/stype/XMFB.html",
- 10: "/list/spxm/",
- 11: "/list/tjxm/",
- 13: "/list/rmxm/",
- 14: "/list/xxxm/",
- 15: "/list/gjxm/",
- 16: "/list/sjxm/",
- 8: "/list/stype/ZFCG.html",
- 20: "/list/nzjxm/",
- }
- )
- func init() {
- xweb.AddAction(&NewIndex{})
- routerRelayMap = map[string]map[bool]string{
- "yxgl": { //【营销管理】根据code判断是否有权限 bi_yx
- true: fmt.Sprintf("/page_workDesktop/work-bench/page?link=%s/succbi/crm_system/app/crm.app/sales_clues.spg", config.Sysconfig["webdomain"].(string)),
- false: "/swordfish/frontPage/digitalMarketing/free/index",
- },
- "yxt": { //【医械通】根据code判断是否有权限 lyh_yl_yldy
- true: "/page_workDesktop/work-bench/app/big/medical/Credentials",
- false: "http://clpages.cn/yxtsjgwyxy",
- },
- "khgl": { //【客户管理】根据code判断是否有权限 bi_yx
- true: fmt.Sprintf("/page_workDesktop/work-bench/page?link=%s/succbi/crm_system/app/crm.app/sales_clues.spg", config.Sysconfig["webdomain"].(string)),
- false: "/swordfish/frontPage/customanage/free/index",
- },
- "tbxmgl": { //【投标项目管理】根据code判断是否有权限 cb_zy_code
- true: "/page_workDesktop/work-bench/app/big/attend_bidding/mine",
- false: "/swordfish/frontPage/biddingProject/free/index",
- },
- "nzbg": { //【年终报告】根据code判断是否有权限
- true: fmt.Sprintf("/page_workDesktop/work-bench/page?link=%s/succbi/nzbg/app/nzbg.app/nzbg_entrance_pc.spg", config.Sysconfig["webdomain"].(string)),
- false: "http://clpages.cn/nzbg",
- },
- "xxfb": { //【信息发布】根据登录否判断
- true: fmt.Sprintf("/page_workDesktop/work-bench/page?link=%s/swordfish/page_web_pc/issued/info", config.Sysconfig["webdomain"].(string)),
- false: "/swordfish/frontPage/InformationDistribution/free/index",
- },
- "scfx": { //【市场分析报告】 根据登录否判断
- true: "/page_workDesktop/work-bench/app/big/desktop/report_analysis",
- false: "/big/page/sc",
- },
- "qdkz": { //【渠道扩展】 根据大会员权益7判断
- true: "/swordfish/page_big_pc/potential_cor_list/c",
- false: "/big/page/yw",
- },
- "tbjc": { //【投标决策分析】 根据大会员权益6判断
- true: "/page_workDesktop/work-bench/app/big/analysis_result",
- false: "/big/page/tb",
- },
- }
- }
- func (nIndex *NewIndex) RouterRelay(code string) {
- toUrl := func() string {
- sessVal := nIndex.Session().GetMultiple()
- accountId := common.Int64All(sessVal["accountId"])
- if accountId <= 0 { //未登录
- return routerRelayMap[code][false]
- }
- if code == "nzbg" || code == "xxfb" || code == "scfx" {
- return routerRelayMap[code][true]
- }
- entAccountId := common.Int64All(sessVal["entAccountId"])
- entId := common.Int64All(sessVal["entId"])
- entUserId := common.Int64All(sessVal["entUserId"])
- res := config.Middleground.ResourceCenter.Haspowers(accountId, entAccountId, entId, entUserId)
- powerPass := false
- switch code {
- case "yxgl", "khgl":
- for _, pCode := range res.Powers {
- if pCode == "bi_yx" {
- powerPass = true
- break
- }
- }
- case "yxt":
- for _, pCode := range res.Powers {
- if pCode == "lyh_yl_yldy" {
- powerPass = true
- break
- }
- }
- case "tbxmgl":
- for _, pCode := range res.Powers {
- if pCode == "cb_zy_code" {
- powerPass = true
- break
- }
- }
- case "tbjc", "qdkz": //大会员权益判断
- powerRes := config.Middleground.PowerCheckCenter.Check("10000", gconv.String(sessVal["mgoUserId"]), gconv.Int64(sessVal["base_user_id"]), gconv.Int64(sessVal["accountId"]), gconv.Int64(sessVal["entId"]), gconv.Int64(sessVal["positionType"]), gconv.Int64(sessVal["positionId"]))
- for _, pInt := range powerRes.Member.MemberPowerList {
- if code == "tbjc" && pInt == 6 {
- powerPass = true
- break
- }
- if code == "qdkz" && pInt == 7 {
- powerPass = true
- break
- }
- }
- }
- return routerRelayMap[code][powerPass]
- }()
- _ = nIndex.Redirect(toUrl)
- }
- // NewIndex 新版首页改版
- func (nIndex *NewIndex) NewIndex() error {
- sessVal := nIndex.Session().GetMultiple()
- userId := util.ObjToString(sessVal["userId"])
- nIndex.T["hasLogin"] = userId != ""
- nIndex.T["hotkey"] = hotKeyArrLoginEd
- nIndex.T["hotKeyArrUnLogin"] = hotKeyArrUnLogin
- if userId != "" {
- nickname, vipType := gconv.String(sessVal["userName"]), "注册用户"
- var endTime int64
- //来源于接口/user/getSimpleData
- phone, _ := sessVal["phone"].(string)
- nickname, _ = common.If(sessVal["s_nickname"] != nil, sessVal["s_nickname"], sessVal["app_name"]).(string)
- if nickname == "" {
- var PhoneReg = regexp.MustCompile(`^(100\d{8}|1[3-9]\d{9})$`)
- if PhoneReg.MatchString(phone) {
- nickname = string(phone[0:3]) + "****" + string(phone[(len(phone)-4):])
- }
- }
- powerRes := config.Middleground.PowerCheckCenter.Check("10000", gconv.String(sessVal["mgoUserId"]), gconv.Int64(sessVal["base_user_id"]), gconv.Int64(sessVal["accountId"]), gconv.Int64(sessVal["entId"]), gconv.Int64(sessVal["positionType"]), gconv.Int64(sessVal["positionId"]))
- if powerRes.Vip.Status > 0 && powerRes.Vip.GetEndTime() > endTime {
- vipType, endTime = "超级订阅", powerRes.Vip.GetEndTime()
- }
- if powerRes.Member.Status > 0 && powerRes.Member.GetEndTime() > endTime {
- vipType, endTime = "大会员", powerRes.Member.GetEndTime()
- }
- if powerRes.Entniche.Status > 0 && powerRes.Entniche.GetEndTime() > endTime {
- vipType, endTime = "商机管理", powerRes.Entniche.GetEndTime()
- }
- if powerRes.Free.PpStatus > 0 && powerRes.Free.PpEndTime > endTime {
- vipType, endTime = "省份订阅包", powerRes.Free.GetPpEndTime()
- }
- nIndex.T["vipType"] = vipType
- nIndex.T["nickname"] = nickname
- if endTime > 0 {
- nIndex.T["vipEntTime"] = time.Unix(endTime, 0).Format("2006-01-02")
- }
- }
- //顶部菜单
- nIndex.T["topMenu"] = g.Cfg("index").MustGet(context.Background(), "topMenu").Maps()
- //招标公告
- biddingList, _ := GetRecommendBidZone(5, 16)
- nIndex.T["newbids"] = map[string]interface{}{
- "biddingList": biddingList,
- "more": fmt.Sprintf("%s", "/list/stype/ZBGG.html"),
- }
- //推荐标讯专区
- rangeInfoType := []int{1, 2}
- //招标动态
- bidTrends := []map[string]interface{}{}
- for _, v := range rangeInfoType { //1招标预告 2 中标成交 3采购意向 4 拟建项目
- listData, types := GetRecommendBidZone(v, 10)
- bidTrends = append(bidTrends, map[string]interface{}{
- "listData": listData,
- "types": types,
- "url": fmt.Sprintf("%s", BiddingTypeUrl[v]),
- })
- }
- //采购意向
- procure, procureName := GetIndexProjectListRedis(5, 10)
- bidTrends = append(bidTrends, map[string]interface{}{
- "listData": procure,
- "types": procureName,
- "url": fmt.Sprintf("%s", BiddingTypeUrl[5]),
- })
- //项目分包
- projectPage, typesName := GetIndexProjectListRedis(6, 10)
- bidTrends = append(bidTrends, map[string]interface{}{
- "listData": projectPage,
- "types": typesName,
- "url": fmt.Sprintf("%s", BiddingTypeUrl[6]),
- })
- nIndex.T["bidTrends"] = bidTrends
- //项目专区
- projectZone := []map[string]interface{}{}
- //拟在建项目
- nzjProject := IndexNzjProject(5)
- projectZone = append(projectZone, map[string]interface{}{
- "listData": nzjProject,
- "types": "拟在建项目",
- "url": fmt.Sprintf("%s", BiddingTypeUrl[20]),
- })
- projectZoneType := []int{10, 11}
- for _, val := range projectZoneType {
- listData, types := GetIndexRecommendProjectList(val, 5)
- projectZone = append(projectZone, map[string]interface{}{
- "listData": listData,
- "types": types,
- "url": fmt.Sprintf("%s", BiddingTypeUrl[val]),
- })
- }
- //热门项目
- listData, types := GetIndexProjectListRedis(13, 10)
- projectZone = append(projectZone, map[string]interface{}{
- "listData": listData,
- "types": types,
- "url": fmt.Sprintf("%s", BiddingTypeUrl[13]),
- })
- nIndex.T["projectZone"] = projectZone
- //中标喜报
- nIndex.T["winnerGlad"] = WinnerGladTidings(10)
- //热门行业 ////重点招标
- nIndex.T["hotIndustry"] = GetHotIndustry()
- //热门中标企业
- nIndex.T["hotWinner"] = NewHotEnt(true, 10)
- //热门采购单位
- nIndex.T["hotBuyers"] = NewHotEnt(false, 5)
- //供应商
- nIndex.T["supplyEnt"] = GetBidInfoPublishEnt()
- //行业分析简报
- nIndex.T["industryReport"] = GetIndustryAnalysisReport()
- //招投标攻略
- nIndex.T["strategyList"] = GetStrategyList()
- //剑鱼课堂
- nIndex.T["jySchool"] = jyutil.Course(6, 3)
- // 政府招标
- nIndex.T["governmentBidding"] = GovernmentTender(15)
- //区县招标
- nIndex.T["districtsBidding"] = DistrictsTender(15)
- nIndex.T["importBidding"] = GetImportBidding()
- //nIndex.T["biddingTrend"] = HomeBiddingTrends()
- nIndex.T["hotBuyerData"] = PurchasingData()
- nIndex.T["simpleTemplateData"] = map[string]interface{}{"XwebVer": nIndex.T["XwebVer"]}
- //文库
- nIndex.T["docsClass"], nIndex.T["docsData"] = GetDocsData()
- return nIndex.Render("/pc/newIndex.html", &nIndex.T)
- }
- func GetDocsData() (docClass []string, indexDocs [][]map[string]interface{}) {
- cacheDocsInfoKey := "jy_index_docs_info"
- cacheDocsClassKey := "jy_index_docs_class"
- if bytes, err := redis.GetBytes(RedisNameNew, cacheDocsInfoKey); err == nil && bytes != nil {
- if err := json.Unmarshal(*bytes, &indexDocs); err != nil {
- log.Printf("[MANAGER-ERR]jy_index_docs_info GetData Error %v \n", err)
- return []string{}, nil
- }
- classNames := redis.GetStr(RedisNameNew, cacheDocsClassKey)
- if classNames == "" {
- return []string{}, nil
- }
- docClass = strings.Split(classNames, ",")
- return
- }
- //浏览量前十的一级分类
- var (
- ossUrl = common.InterfaceToStr(config.Sysconfig["ossUrl"]) // "https://jydocs-previewimg.oss-cn-beijing.aliyuncs.com/%s"
- docinUrl = common.InterfaceToStr(config.Sysconfig["docinUrl"]) //"https://img3.douding.cn/docin_%s_90x80.jpg"
- )
- //浏览量前十的一级分类
- docClassNames := config.Sysconfig["indexDocClass"].([]interface{})
- if docClassNames != nil && len(docClassNames) > 0 {
- indexDoc := []map[string]interface{}{}
- //docSql := `SELECT d.id,d.docName,d.docFileSuffix,d.docTags,d.previewImgId,d.productType,d.source FROM jydocs.doc d LEFT JOIN jydocs.doc_statistics ds ON d.id=ds.docId WHERE FIND_IN_SET(?,d.docTags) ORDER BY ds.viewTimes DESC LIMIT 10 `
- var docFormatFunc = func(docs *[]map[string]interface{}) {
- for dock, docv := range *docs {
- if dock > 7 {
- break
- }
- previewImg := fmt.Sprintf(ossUrl, common.InterfaceToStr(docv["previewImgId"]))
- if common.IntAll(docv["source"]) == 2 {
- previewImg = fmt.Sprintf(docinUrl, common.InterfaceToStr(docv["previewImgId"]))
- }
- fileSuffix := common.InterfaceToStr(docv["docFileSuffix"])
- //文件类型,1 doc 2 pdf 3 xls 4 ppt 5 txt 6 其他
- docFileType := common.IntAll(docv["docFileType"])
- switch docFileType {
- case 1:
- fileSuffix = "doc"
- case 2:
- fileSuffix = "pdf"
- case 3:
- fileSuffix = "xls"
- case 4:
- fileSuffix = "ppt"
- case 5:
- fileSuffix = "txt"
- default:
- fileSuffix = "其他"
- }
- //if strings.HasPrefix(fileSuffix, ".") {
- // fileSuffix = strings.ReplaceAll(fileSuffix, ".", "")
- //}
- indexDoc = append(indexDoc, map[string]interface{}{
- "id": common.InterfaceToStr(docv["id"]),
- "docName": common.InterfaceToStr(docv["docName"]),
- "docFileSuffix": fileSuffix,
- "previewImg": previewImg,
- "productType": common.IntAll(docv["productType"]),
- })
- }
- }
- for _, dv := range docClassNames {
- tmpClass := common.ObjToMap(dv)
- if tmpClass == nil {
- continue
- }
- name := common.InterfaceToStr((*tmpClass)["class"])
- search := common.InterfaceToStr((*tmpClass)["search"])
- code := common.InterfaceToStr((*tmpClass)["code"])
- //2.0 推荐表数据
- var docByTidb = func() {
- docSql := fmt.Sprintf(`SELECT d.id, d.docName, d.docFileType, d.docFileSuffix, d.previewImgId, d.productType, d.source FROM doc d LEFT JOIN doc_recommend dr ON d.id = dr.doc_id WHERE dr.region_state = 1 AND dr.doc_class_code = '%s' ORDER BY dr.create_date DESC;`, code)
- docs := public.BaseMysql.SelectBySql(docSql)
- if docs != nil && len(*docs) > 0 {
- docFormatFunc(docs)
- }
- }
- docByTidb()
- //1.0 查es
- var docByEs = func() {
- query := fmt.Sprintf(`{"query":{"bool":{"must":[{"term":{"docTags":"%s"}}]}},"size":10,"sort":[{"viewTimes":"desc"}]}`, search)
- docs := public.Doc.Get("jydoc", "jydoc", query)
- //docs := public.BaseMysql.SelectBySql(docSql, search)
- if docs != nil && len(*docs) > 0 {
- docFormatFunc(docs)
- }
- }
- if len(indexDoc) == 0 {
- docByEs()
- }
- if len(indexDoc) > 0 {
- docClass = append(docClass, name)
- indexDocs = append(indexDocs, indexDoc)
- //
- indexDoc = []map[string]interface{}{}
- }
- }
- }
- if len(indexDocs) > 0 {
- b, err := json.Marshal(indexDocs)
- if err == nil && len(b) > 0 {
- err = redis.PutBytes(RedisNameNew, cacheDocsInfoKey, &b, 12*60*60)
- if err != nil {
- log.Println(fmt.Sprintf("首页 文库数据 缓存 %s,保存异常:%s", cacheDocsInfoKey, err.Error()))
- }
- }
- if len(docClass) > 0 {
- if b := redis.Put(RedisNameNew, cacheDocsClassKey, strings.Join(docClass, ","), 12*60*60); !b {
- log.Println(fmt.Sprintf("首页 文库分类 缓存 %s,保存异常", cacheDocsClassKey))
- }
- }
- }
- return
- }
- func (nIndex *NewIndex) AppDownload() {
- nIndex.T["includedInfo"] = GetIncludedInfo()
- nIndex.Render("/frontRouter/pc/AppDownload/free/index.html", &nIndex.T)
- }
- // 推荐标讯专区
- func GetRecommendBidZone(typ int, pageSize int) (list []map[string]interface{}, typs string) {
- if typ == 0 {
- typ = 1
- }
- sql := ""
- switch typ {
- case 1:
- //招标预告
- typs = "招标预告"
- sql = fmt.Sprintf(" AND toptype = '%s' ", "预告")
- case 2:
- //招标中标成交
- typs = "中标成交"
- sql = fmt.Sprintf(" AND subtype = '%s' or subtype = '%s' ", "中标", "成交")
- /*case 3:
- //采购意向
- typs = "采购意向"
- sql = fmt.Sprintf(" AND toptype = '%s' ", "采购意向")*/
- case 4:
- //拟建
- typs = "拟建项目"
- sql = fmt.Sprintf(" AND toptype = '%s' ", "拟建")
- case 5:
- typs = "招标公告"
- sql = fmt.Sprintf(" AND toptype = '%s' ", "招标")
- }
- rediskey := fmt.Sprintf("pcIndexRecommendBidZone_%d", typ)
- if l, ok := redis.Get(RedisNameNew, rediskey).([]interface{}); ok && l != nil && len(l) > 0 {
- list = common.ObjArrToMapArr(l)
- return list, typs
- }
- queryRes, err := g.DB().Query(gctx.New(), fmt.Sprintf(`SELECT b.bid_id
- FROM new_areaClass b
- WHERE 1=1 %s
- ORDER BY b.publish_time DESC
- LIMIT 0,?`, sql), pageSize)
- if err != nil || queryRes.IsEmpty() {
- return nil, ""
- }
- finalArr := FillingBiddingBaseFields(gctx.New(), queryRes.List(), typs)
- if finalArr != nil && len(finalArr) > 0 {
- redis.Put(RedisNameNew, rediskey, finalArr, g.Cfg("index").MustGet(context.Background(), "indexBiddingCacheTime", 1800).Int())
- }
- return finalArr, typs
- }
- func FillingBiddingBaseFields(ctx context.Context, res []map[string]interface{}, typs string) []map[string]interface{} {
- bidIdStrings := make([]string, 0, len(res))
- for _, m := range res {
- if bidId := gconv.String(m["bid_id"]); bidId != "" {
- bidIdStrings = append(bidIdStrings, bidId)
- }
- }
- bidRes, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT * FROM new_bidList WHERE toptype !='拟建' AND bid_id IN ('%s')`, strings.Join(bidIdStrings, "','")))
- if bidRes.IsEmpty() {
- return nil
- }
- bidMap := map[string]map[string]interface{}{}
- titleReduction := map[string]bool{}
- for _, m := range bidRes.List() {
- if bidIdStr := gconv.String(m["bid_id"]); bidIdStr != "" {
- //重复标题加数字后缀
- if titleReduction[gconv.String(m["title"])] {
- continue
- }
- titleReduction[gconv.String(m["title"])] = true
- m["_id"] = encrypt.EncodeArticleId2ByCheck(common.ObjToString(m["bid_id"]))
- if typs == "招标公告" {
- m["publish_time"] = time.Unix(common.Int64All(m["publish_time"]), 0).Format("01-02")
- } else {
- m["publish_time"] = time.Unix(common.Int64All(m["publish_time"]), 0).Format("2006-01-02")
- }
- bidMap[bidIdStr] = m
- }
- }
- var finalArr []map[string]interface{}
- for i := 0; i < len(res); i++ {
- if tBid := gconv.String(res[i]["bid_id"]); tBid != "" && bidMap[tBid] != nil && len(bidMap[tBid]) > 0 {
- for k, v := range bidMap[tBid] {
- res[i][k] = v
- }
- finalArr = append(finalArr, res[i])
- }
- }
- return finalArr
- }
- // GetStrategyList 招投标攻略
- func GetStrategyList() (strategyList []map[string]interface{}) {
- /*if l, ok := redis.Get(RedisNameNew, "pcIndexStrategyList").([]interface{}); ok && l != nil && len(l) > 0 {
- strategyList = common.ObjArrToMapArr(l)
- } else {*/
- for _, item := range jySchool.GuidelineColumn().SeedData {
- if res := jySchool.Guideline(item.Code, 15); res != nil && len(*res) > 0 {
- strategyList = append(strategyList, map[string]interface{}{
- "name": item.Name,
- "code": item.Code,
- "list": res,
- })
- }
- }
- //}
- return strategyList
- }
- func GetIndexProjectList(typ, pageSize int, resArr []map[string]interface{}) (data []map[string]interface{}, types string) {
- if len(resArr) > 5 {
- return resArr[:5], types
- }
- res, err := g.DB().Query(gctx.New(), fmt.Sprintf(`SELECT bid_id,publish_time,bitmapToArray(sign) FROM new_bid_sign WHERE bitmapContains(sign, %d) ORDER BY publish_time DESC LIMIT %d, %d`, typ, pageSize-10, 10))
- if err != nil || res.IsEmpty() {
- return nil, types
- }
- finalArr := FillingBiddingBaseFields(gctx.New(), res.List(), types)
- if len(finalArr) > 5 {
- finalArr = finalArr[:5]
- }
- resArr = append(resArr, finalArr...)
- return GetIndexProjectList(typ, pageSize+10, resArr)
- }
- func GetIndexProjectListRedis(typ, pageSize int) (data []map[string]interface{}, types string) {
- switch typ {
- case 5:
- types = "采购意向"
- case 6:
- types = "项目分包"
- case 13:
- types = "热门项目"
- case 14:
- types = "新兴项目"
- case 15:
- types = "国家级项目"
- case 16:
- types = "省级项目"
- case 8:
- types = "政府采购"
- }
- redidKey := fmt.Sprintf("pcIndexProjectZone_%d", typ)
- redisArr, _ := redis.Get(RedisNameNew, redidKey).([]interface{})
- if len(redisArr) > 0 {
- data = common.ObjArrToMapArr(redisArr)
- return
- }
- data, _ = GetIndexProjectList(typ, pageSize, []map[string]interface{}{})
- if data != nil && len(data) > 0 {
- redis.Put(RedisNameNew, redidKey, data, RedisTimeout+rand.Intn(100))
- }
- return data, types
- }
- // GetIndexRecommendProjectList 审批项目、推荐项目
- func GetIndexRecommendProjectList(typ, pageSize int) (data []map[string]interface{}, types string) {
- switch typ {
- case 10:
- types = "审批项目"
- case 11:
- types = "推荐项目"
- }
- redidKey := fmt.Sprintf("pcIndexProjectZone_%d", typ)
- redisArr, _ := redis.Get(RedisNameNew, redidKey).([]interface{})
- if len(redisArr) > 0 {
- data = common.ObjArrToMapArr(redisArr)
- return
- }
- res, err := g.DB().Query(gctx.New(), fmt.Sprintf(`SELECT bid_id,title,publish_time FROM new_project_sign WHERE bitmapContains(sign, %d) ORDER BY publish_time DESC LIMIT 0, %d`, typ, pageSize))
- if err != nil || res.IsEmpty() {
- return nil, types
- }
- for _, v := range res.List() {
- v["proposed_id"] = encrypt.SE2.Encode2Hex(common.ObjToString(v["bid_id"]))
- v["publish_time"] = strings.Split(common.InterfaceToStr(v["publish_time"]), " ")[0]
- data = append(data, v)
- }
- if data != nil && len(data) > 0 {
- redis.Put(RedisNameNew, redidKey, data, RedisTimeout+rand.Intn(100))
- }
- return data, types
- }
- // 优秀供应商
- func GetBidInfoPublishEnt() (res [][]map[string]interface{}) {
- if l, ok := redis.Get(RedisNameNew, "pcIndexBidInfoGoodPublishEnt").([]interface{}); ok && l != nil && len(l) > 0 {
- for _, v := range l {
- res = append(res, common.ObjArrToMapArr(v.([]interface{})))
- }
- } else {
- data := public.Mysql.Query("SELECT id,name FROM `entniche_info` WHERE auth_status = 1 ORDER BY auth_startTime DESC")
- if data != nil && len(*data) > 0 {
- resData := []map[string]interface{}{}
- for _, val := range *data {
- if strings.Contains(common.ObjToString(val["name"]), "测试") || strings.Contains(common.ObjToString(val["name"]), "账号") {
- continue
- } else {
- resData = append(resData, val)
- }
- }
- entData := []map[string]interface{}{}
- if len(resData) > 110 {
- r := rand.Intn(len(resData) - 110)
- entData = (resData)[r : r+110]
- } else {
- entData = resData
- }
- if len(entData) > 0 {
- once := []map[string]interface{}{}
- for _, val := range entData {
- if len(once) <= 10 {
- once = append(once, val)
- } else {
- res = append(res, once)
- once = []map[string]interface{}{}
- once = append(once, val)
- }
- }
- if len(once) > 0 {
- res = append(res, once)
- }
- }
- redis.Put(RedisNameNew, "pcIndexBidInfoGoodPublishEnt", res, RedisTimeout+rand.Intn(100))
- }
- }
- return res
- }
- func GetImportBidding() []*hotKeyWord {
- redisData := redis.Get(RedisNameNew, "pcIndexImportBidding")
- if redisData != nil {
- if d, err := json.Marshal(redisData); err == nil {
- var hotKW []*hotKeyWord
- json.Unmarshal(d, &hotKW)
- return hotKW
- }
- }
- randomNumber := rand.Intn(len(subjectMatter) - 30)
- res := subjectMatter[randomNumber : randomNumber+30]
- if len(res) > 0 {
- redis.Put(RedisNameNew, "pcIndexImportBidding", res, RedisTimeout+rand.Intn(100))
- }
- 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 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
- }
|