|
@@ -1,10 +1,10 @@
|
|
|
package service
|
|
|
|
|
|
import (
|
|
|
- "app.yhyue.com/moapp/jybase/encrypt"
|
|
|
"context"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
+ "jy/src/jfw/modules/subscribepay/src/config"
|
|
|
"jy/src/jfw/modules/subscribepay/src/util"
|
|
|
"log"
|
|
|
"net/http"
|
|
@@ -12,8 +12,11 @@ import (
|
|
|
"sync"
|
|
|
|
|
|
qutil "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/mongodb"
|
|
|
"app.yhyue.com/moapp/jybase/redis"
|
|
|
+ "app.yhyue.com/moapp/jypkg/common/src/qfw/util/dataexport"
|
|
|
)
|
|
|
|
|
|
type Network struct {
|
|
@@ -32,6 +35,11 @@ func (n *Network) ProjectExport() {
|
|
|
pool := make(chan bool, 3)
|
|
|
wait := &sync.WaitGroup{}
|
|
|
lock := &sync.Mutex{}
|
|
|
+ version := n.GetString("version")
|
|
|
+ tableName := "transaction_info"
|
|
|
+ if version == "1" {
|
|
|
+ tableName = "transaction_info_all"
|
|
|
+ }
|
|
|
for _, v := range strings.Split(exportIds, ",") {
|
|
|
args = append(args, v)
|
|
|
wh = append(wh, "?")
|
|
@@ -43,7 +51,7 @@ func (n *Network) ProjectExport() {
|
|
|
<-pool
|
|
|
wait.Done()
|
|
|
}()
|
|
|
- ids := n.search(wh1, args1)
|
|
|
+ ids := n.search(tableName, wh1, args1)
|
|
|
lock.Lock()
|
|
|
bIds = append(bIds, ids...)
|
|
|
lock.Unlock()
|
|
@@ -54,27 +62,53 @@ func (n *Network) ProjectExport() {
|
|
|
}
|
|
|
wait.Wait()
|
|
|
if len(args) > 0 {
|
|
|
- bIds = append(bIds, n.search(wh, args)...)
|
|
|
+ bIds = append(bIds, n.search(tableName, wh, args)...)
|
|
|
}
|
|
|
if len(bIds) == 0 {
|
|
|
return
|
|
|
}
|
|
|
- //bidList, err := dataexport.GetDataExportSearchResult(util.Mgo_bidding, config.Config.Mongobidding.DbName, config.Config.Elasticsearch, scd, "2", -2)
|
|
|
- log.Println("bIds---", bIds)
|
|
|
- bidList, err := GetDataSearchResult(bIds)
|
|
|
- if err != nil {
|
|
|
- log.Println("人脉通项目导出", export_id, err)
|
|
|
- http.Error(n.ResponseWriter, err.Error(), http.StatusInternalServerError)
|
|
|
+ //通用版
|
|
|
+ var dataErr error
|
|
|
+ bidList := map[string][]util.Information{}
|
|
|
+ if version == "1" {
|
|
|
+ datas, err := dataexport.GetDataExportSearchResult(util.Mgo_bidding, config.Config.Mongobidding.DbName, config.Config.Elasticsearch, &dataexport.SieveCondition{SelectIds: bIds}, "2", -2)
|
|
|
+ dataErr = err
|
|
|
+ if err == nil && datas != nil && len(*datas) > 0 {
|
|
|
+ for _, v := range *datas {
|
|
|
+ toptype := qutil.ObjToString(v["toptype"])
|
|
|
+ im := util.Information{
|
|
|
+ Title: qutil.ObjToString(v["title"]),
|
|
|
+ Buyer: qutil.ObjToString(v["buyer"]),
|
|
|
+ Href: fmt.Sprintf("%s/article/content/%s.html", config.Config.WebDomain, encrypt.EncodeArticleId2ByCheck(BsonIdToSId(v["_id"]))),
|
|
|
+ Class: qutil.ObjToString(v["subtype"]),
|
|
|
+ DataJsonId: BsonIdToSId(v["_id"]),
|
|
|
+ Area: strings.Trim(fmt.Sprintf("%s-%s", qutil.ObjToString(v["area"]), qutil.ObjToString(v["city"])), "-"),
|
|
|
+ }
|
|
|
+ if v["bidamount"] != nil {
|
|
|
+ im.Amount = qutil.Float64All(v["bidamount"]) / 10000
|
|
|
+ } else {
|
|
|
+ im.Amount = qutil.Float64All(v["budget"]) / 10000
|
|
|
+ }
|
|
|
+ bidList[toptype] = append(bidList[toptype], im)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else { //物业版
|
|
|
+ bidList, dataErr = GetDataSearchResult(bIds)
|
|
|
+ }
|
|
|
+ if dataErr != nil {
|
|
|
+ log.Println("人脉通项目导出", export_id, dataErr)
|
|
|
+ http.Error(n.ResponseWriter, dataErr.Error(), http.StatusInternalServerError)
|
|
|
return
|
|
|
- } else if bidList == nil || len(bidList) == 0 {
|
|
|
- log.Println("人脉通项目导出", export_id, "未找到标讯的情报信息")
|
|
|
- http.Error(n.ResponseWriter, "未找到标讯的情报信息", http.StatusInternalServerError)
|
|
|
+ } else if len(bidList) == 0 {
|
|
|
+ log.Println("人脉通项目导出", export_id, "未找到标讯信息")
|
|
|
+ http.Error(n.ResponseWriter, "未找到标讯信息", http.StatusInternalServerError)
|
|
|
return
|
|
|
}
|
|
|
- log.Println("人脉通项目导出", export_id, bidList)
|
|
|
- file, err := util.ExportExcelFileForNw(bidList)
|
|
|
- if err != nil {
|
|
|
- http.Error(n.ResponseWriter, err.Error(), http.StatusInternalServerError)
|
|
|
+ log.Println("人脉通项目导出", export_id, len(bidList))
|
|
|
+ file, fileErr := util.ExportExcelFileForNw(version, bidList)
|
|
|
+ if fileErr != nil {
|
|
|
+ log.Println("人脉通项目导出", export_id, fileErr)
|
|
|
+ http.Error(n.ResponseWriter, fileErr.Error(), http.StatusInternalServerError)
|
|
|
return
|
|
|
}
|
|
|
// 设置响应头
|
|
@@ -87,9 +121,9 @@ func (n *Network) ProjectExport() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func (n *Network) search(wh []string, args []interface{}) []string {
|
|
|
+func (n *Network) search(tableName string, wh []string, args []interface{}) []string {
|
|
|
bIds := []string{}
|
|
|
- rows, err := util.ClickhouseConn.Query(context.Background(), `select info_id,info_ids from information.transaction_info where project_id in (`+strings.Join(wh, ",")+`)`, args...)
|
|
|
+ rows, err := util.ClickhouseConn.Query(context.Background(), `select info_id,info_ids from information.`+tableName+` where project_id in (`+strings.Join(wh, ",")+`)`, args...)
|
|
|
if err != nil {
|
|
|
log.Println(err)
|
|
|
return bIds
|
|
@@ -120,9 +154,7 @@ func (n *Network) search(wh []string, args []interface{}) []string {
|
|
|
|
|
|
func GetDataSearchResult(ids []string) (result map[string][]util.Information, err error) {
|
|
|
result = make(map[string][]util.Information)
|
|
|
- q := fmt.Sprintf(`select id, title, summary, content, basis, area, city, datajson, class, datajson_id from information.information where datajson_id in ('%s')`,
|
|
|
- strings.Join(ids, "', '"))
|
|
|
- log.Println(q)
|
|
|
+ q := fmt.Sprintf(`select id, title, summary, content, basis, area, city, datajson, class, datajson_id from information.information where datajson_id in ('%s')`, strings.Join(ids, "', '"))
|
|
|
rows, err := util.ClickhouseConn.Query(context.Background(), q)
|
|
|
if err != nil {
|
|
|
log.Println(err)
|
|
@@ -134,7 +166,7 @@ func GetDataSearchResult(ids []string) (result map[string][]util.Information, er
|
|
|
if info.DataJson != "" {
|
|
|
m := make(map[string]interface{})
|
|
|
err = json.Unmarshal([]byte(info.DataJson), &m)
|
|
|
- info.Area = fmt.Sprintf("%s-%s", info.Area, info.City)
|
|
|
+ info.Area = strings.Trim(fmt.Sprintf("%s-%s", info.Area, info.City), "-")
|
|
|
if err == nil {
|
|
|
info.Buyer = qutil.ObjToString(m["buyer"])
|
|
|
if m["bidamount"] != nil {
|
|
@@ -145,9 +177,9 @@ func GetDataSearchResult(ids []string) (result map[string][]util.Information, er
|
|
|
}
|
|
|
}
|
|
|
if info.Class == "采购意向" || info.Class == "招标项目" {
|
|
|
- info.Href = fmt.Sprintf("https://www.jianyu360.cn/article/content/%s.html", encrypt.EncodeArticleId2ByCheck(info.DataJson))
|
|
|
+ info.Href = fmt.Sprintf("%s/article/content/%s.html", config.Config.WebDomain, encrypt.EncodeArticleId2ByCheck(info.DataJsonId))
|
|
|
} else {
|
|
|
- info.Href = fmt.Sprintf("https://www.jianyu360.cn/succbi/crm_system/app/crm.app/专属资讯/business_information3_deteil.spg?E_original_intelligence_id=%s", info.Id)
|
|
|
+ info.Href = fmt.Sprintf("%s/succbi/crm_system/app/crm.app/专属资讯/business_information3_deteil.spg?E_original_intelligence_id=%s", config.Config.WebDomain, info.Id)
|
|
|
}
|
|
|
if result[info.Class] != nil {
|
|
|
result[info.Class] = append(result[info.Class], info)
|