Sfoglia il codice sorgente

周报月报查询修改

WH01243 1 anno fa
parent
commit
d71febb5f3

+ 21 - 2
src/jfw/modules/bigmember/src/entity/report.go

@@ -26,7 +26,7 @@ type ReportProjectInfoParam struct {
 	End        int                 `json:"end"`        // 结束时间
 	PageSize   int                 `json:"pageSize"`   // 默认每页10条
 	PageNum    int                 `json:"pageNum"`    // 默认当前第一页
-	Form       string              `json:"form"`       // 来源
+	From       string              `json:"from"`       // 来源
 }
 
 // GetReportProjectInfo 周报/月报查询项目明细
@@ -107,7 +107,7 @@ func GetReportProjectInfo(param *ReportProjectInfoParam, positionId int64) (data
 	q += strings.Join(qstr, " and ")
 	// 查询数量
 	table := TableMemberReportProject
-	if param.Form == From {
+	if param.From == From {
 		table = TableMemberReportProjectYys
 	}
 	CountQuery := fmt.Sprintf("select count(1) from %s where position_id=? and start_time>=? and end_time<=? %s ", table, q)
@@ -150,8 +150,10 @@ func ReportProjectInfoFormat(data []map[string]interface{}) []map[string]interfa
 		tmp["area"] = data[i]["area"]
 		tmp["bidStatus"] = data[i]["bidstatus"]
 		tmp["buyerClass"] = data[i]["buyerclass"]
+		tmp["subscopeclass"] = data[i]["subscopeclass"]
 		tmp["bidAmount"] = data[i]["bidamount"]
 		tmp["budget"] = data[i]["budget"]
+		tmp["item"] = data[i]["items"]
 		tmp["buyer"] = data[i]["buyer"]
 		tmp["lastTime"] = data[i]["last_time"]
 		rs = append(rs, tmp)
@@ -204,6 +206,23 @@ func ReportGetBuyerClass(positionId, start, end int64, from string) []string {
 	return buyerClass
 }
 
+// ReportGetIndustry 周报月报获取当前行业
+func ReportGetIndustry(positionId, start, end int64, from string) []string {
+	subscopeclass := []string{}
+	table := TableMemberReportProject
+	if from == From {
+		table = TableMemberReportProjectYys
+	}
+	q := "select distinct(subscopeclass) from " + table + " where position_id =? and start_time >=? and end_time<=?  order by subscopeclass "
+	rs := db.Base.SelectBySql(q, positionId, start, end)
+	if rs != nil && len(*rs) > 0 {
+		for i := 0; i < len(*rs); i++ {
+			subscopeclass = append(subscopeclass, common.ObjToString((*rs)[i]["subscopeclass"]))
+		}
+	}
+	return subscopeclass
+}
+
 // GetMainPositionId 根据用户id获取主账号的职位id
 func GetMainPositionId(mgoUserId string) (positionId int64) {
 	// 1. 查主账号的base_user_id

+ 23 - 16
src/jfw/modules/bigmember/src/service/report/report.go

@@ -3,6 +3,7 @@ package report
 import (
 	"encoding/json"
 	"fmt"
+	"github.com/gogf/gf/v2/util/gconv"
 	"jy/src/jfw/modules/bigmember/src/config"
 	. "jy/src/jfw/modules/bigmember/src/db"
 	"jy/src/jfw/modules/bigmember/src/entity"
@@ -73,7 +74,7 @@ func (r *Report) Index() {
 	ym := r.GetString("ym")
 	from := r.GetString("from")
 	result := M{}
-	userId, qk, qv := getQuery(r.Session())
+	userId, qk, qv := getQuery(r.Session(), from)
 	if qk == "" || qv == nil {
 		return
 	}
@@ -163,7 +164,7 @@ func (r *Report) Detail() {
 	end, _ := r.GetInt("end")
 	from := r.GetString("from")
 	var m M
-	userId, qk, qv := getQuery(r.Session())
+	userId, qk, qv := getQuery(r.Session(), from)
 	if qk == "" || qv == nil {
 		return
 	}
@@ -200,6 +201,9 @@ func (r *Report) Detail() {
 	// 采购单位类型
 	m["buyerClass"] = entity.ReportGetBuyerClass(positionId, start, end, from)
 	m["isNewData"] = isNewData
+	if from == From {
+		m["industry"] = entity.ReportGetIndustry(positionId, start, end, from)
+	}
 	r.ServeJson(Result{
 		Data: m,
 	})
@@ -264,7 +268,7 @@ func weekResult(qk string, qv interface{}, start, end int64, coll, coll_winner s
 			"$lte": end,
 		},
 		"type": 2,
-	}, `{"startdate":1}`, `{"startdate":1,"type":1,"item":1,"bidamount":1,"budget":1,"zhao_matchitem":1,"zhong_matchitem":1,"follow_project":1,"follow_ent":1,"nextweek_bidopen":1,"project_amount":1}`, false, 0, 2)
+	}, `{"startdate":1}`, `{"startdate":1,"type":1,"item":1,"industry":1,bidamount":1,"budget":1,"zhao_matchitem":1,"zhong_matchitem":1,"follow_project":1,"follow_ent":1,"nextweek_bidopen":1,"project_amount":1}`, false, 0, 2)
 	result := M{}
 	prevWeek := map[string]interface{}{}
 	if ok && list != nil {
@@ -275,6 +279,8 @@ func weekResult(qk string, qv interface{}, start, end int64, coll, coll_winner s
 			}
 			//订阅关键词组
 			result["item"] = v["item"]
+			//行业
+			result["industry"] = v["industry"]
 			//本周新增招标项目数量
 			result["zhao_matchitem"] = v["zhao_matchitem"]
 			//本周新增开标项目数量
@@ -310,7 +316,7 @@ func monthResult(userId, qk string, qv interface{}, start, end int64, coll, coll
 		"enddate": map[string]interface{}{
 			"$lte": end,
 		},
-	}, `{"startdate":1}`, `{"startdate":1,"item":1,"project_matchitem_count":1,"project_matchitem_bidamount":1,"project_count":1,"project_bidamount_count":1,"project_area_count":1,"project_area_bidamount":1,"project_buyerclass_count":1,"project_buyerclass_bidamount":1,"project_buyerclass_average_bidamount":1,"winner_area":1,"buyer":1,"winner":1,"project_bidamount":1,"winner_capital_array":1,"winner_project":1}`, false, -1, -1)
+	}, `{"startdate":1}`, `{"startdate":1,"item":1,"industry":1,project_matchitem_count":1,"project_matchitem_bidamount":1,"project_count":1,"project_bidamount_count":1,"project_area_count":1,"project_area_bidamount":1,"project_buyerclass_count":1,"project_buyerclass_bidamount":1,"project_buyerclass_average_bidamount":1,"winner_area":1,"buyer":1,"winner":1,"project_bidamount":1,"winner_capital_array":1,"winner_project":1}`, false, -1, -1)
 	if ok && sixDatas != nil {
 		project_count := &BarCharts{
 			Keys: map[int64]bool{},
@@ -327,6 +333,8 @@ func monthResult(userId, qk string, qv interface{}, start, end int64, coll, coll
 			} else if startdate == start { //本月
 				//订阅关键词组
 				result["item"] = v["item"]
+				//行业
+				result["industry"] = v["industry"]
 				//本月项目规模
 				result["project_matchitem_count"] = v["project_matchitem_count"]
 				//本月项目规模
@@ -526,19 +534,15 @@ func getGrowthRate(v1, v2 float64) float64 {
 }
 
 func (r *Report) Tip() {
-	_, qk, qv := getQuery(r.Session())
+	_, qk, qv := getQuery(r.Session(), "")
 	if qk == "" || qv == nil {
 		return
 	}
-	table := pushspace_member_statistic
-	if from == From {
-		table = pushspace_member_statistic_yys
-	}
-	unread := Mgo.Count(table, map[string]interface{}{
+	unread := Mgo.Count(pushspace_member_statistic, map[string]interface{}{
 		qk:       qv,
 		"unread": 1,
 	})
-	list, ok := Mgo.Find(table, map[string]interface{}{
+	list, ok := Mgo.Find(pushspace_member_statistic, map[string]interface{}{
 		qk:    qv,
 		"tip": 1,
 	}, `{"enddate":-1}`, `{"_id":0,"type":1,"startdate":1,"enddate":1,"pushcount":1}`, false, 0, 1)
@@ -551,7 +555,7 @@ func (r *Report) Tip() {
 	r.ServeJson(result)
 }
 func (r *Report) Tipover() {
-	_, qk, qv := getQuery(r.Session())
+	_, qk, qv := getQuery(r.Session(), "")
 	if qk == "" || qv == nil {
 		return
 	}
@@ -569,7 +573,7 @@ func tipover(qk string, qv interface{}, coll string) bool {
 	}, false, true)
 }
 func (r *Report) Openpushmsg() error {
-	userId, qk, qv := getQuery(r.Session())
+	userId, qk, qv := getQuery(r.Session(), "")
 	pushcount, _ := r.GetInteger("pushcount")
 	positionType := qutil.Int64All(r.GetSession("positionType"))
 	start, _ := r.GetInt("start")
@@ -598,11 +602,11 @@ func (r *Report) Openpushmsg() error {
 }
 
 func (r *Report) Starttime() {
-	_, qk, qv := getQuery(r.Session())
+	from := r.GetString("from")
+	_, qk, qv := getQuery(r.Session(), from)
 	if qk == "" || qv == nil {
 		return
 	}
-	from := r.GetString("from")
 	table := pushspace_member_statistic
 	if from == From {
 		table = pushspace_member_statistic_yys
@@ -658,9 +662,12 @@ func isFree(userId string, positionType int64, session *httpsession.Session) boo
 	return false
 }
 
-func getQuery(sess *httpsession.Session) (string, string, interface{}) {
+func getQuery(sess *httpsession.Session, from string) (string, string, interface{}) {
 	sessMap := sess.GetMultiple()
 	userId := qutil.ObjToString(sessMap["userId"])
+	if from == From {
+		return userId, "userid", gconv.String(sessMap["positionId"])
+	}
 	if qutil.IntAll(sessMap["positionType"]) == 1 {
 		return userId, "ent_userid", qutil.IntAll(sessMap["entUserId"])
 	} else {