|
@@ -3,10 +3,13 @@ package service
|
|
import (
|
|
import (
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
"app.yhyue.com/moapp/jybase/encrypt"
|
|
"app.yhyue.com/moapp/jybase/encrypt"
|
|
|
|
+ "app.yhyue.com/moapp/jybase/redis"
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"fmt"
|
|
"fmt"
|
|
|
|
+ "google.golang.org/protobuf/types/known/anypb"
|
|
"jyBXCore/rpc/bxcore"
|
|
"jyBXCore/rpc/bxcore"
|
|
IC "jyBXCore/rpc/init"
|
|
IC "jyBXCore/rpc/init"
|
|
|
|
+ "log"
|
|
"strings"
|
|
"strings"
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
@@ -24,7 +27,7 @@ type ParticipateStatistics struct {
|
|
EntUserId int64
|
|
EntUserId int64
|
|
}
|
|
}
|
|
|
|
|
|
-func (in *ParticipateStatistics) PushStatistics(entUserIdArr []string, startTime, endTime int64, source int64) (result []*bxcore.PushStatisticsData) {
|
|
|
|
|
|
+func (in *ParticipateStatistics) PushStatistics(entUserIdArr []string, startTime, endTime int64, source []int64) (result []*bxcore.PushStatisticsData) {
|
|
//判断是企业、部门还是个人
|
|
//判断是企业、部门还是个人
|
|
isAdmin, personArrStr, users := in.PersonHandle(entUserIdArr)
|
|
isAdmin, personArrStr, users := in.PersonHandle(entUserIdArr)
|
|
//时间处理
|
|
//时间处理
|
|
@@ -40,7 +43,7 @@ func (in *ParticipateStatistics) PushStatistics(entUserIdArr []string, startTime
|
|
func (in *ParticipateStatistics) ProjectStatistics(entUserIdArr []string, startTime, endTime, bidWay int64) (result []*bxcore.ProjectStatisticsData) {
|
|
func (in *ParticipateStatistics) ProjectStatistics(entUserIdArr []string, startTime, endTime, bidWay int64) (result []*bxcore.ProjectStatisticsData) {
|
|
//判断是企业、部门还是个人
|
|
//判断是企业、部门还是个人
|
|
isAdmin, personArrStr, users := in.PersonHandle(entUserIdArr)
|
|
isAdmin, personArrStr, users := in.PersonHandle(entUserIdArr)
|
|
- query := QueryHandle(isAdmin, startTime, endTime, personArrStr, -1, bidWay)
|
|
|
|
|
|
+ query := QueryHandle(isAdmin, startTime, endTime, personArrStr, []int64{}, bidWay)
|
|
//订阅推送数处理
|
|
//订阅推送数处理
|
|
//推送数据查询
|
|
//推送数据查询
|
|
dataList := IC.BaseMysql.SelectBySql(fmt.Sprintf("select * from participate_project_statistics where %s order by ymd", strings.Join(query, "and ")))
|
|
dataList := IC.BaseMysql.SelectBySql(fmt.Sprintf("select * from participate_project_statistics where %s order by ymd", strings.Join(query, "and ")))
|
|
@@ -50,6 +53,58 @@ func (in *ParticipateStatistics) ProjectStatistics(entUserIdArr []string, startT
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+var (
|
|
|
|
+ SelectItemMap = map[int]string{
|
|
|
|
+ 1: "个人订阅",
|
|
|
|
+ 2: "企业自动分发",
|
|
|
|
+ 3: "企业手动分发",
|
|
|
|
+ }
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+// GetSourceItem 获取标讯项目来源筛选项
|
|
|
|
+func (in *ParticipateStatistics) GetSourceItem(entId, positionId int) (result []*bxcore.SourceItem) {
|
|
|
|
+ redisKey := "sourceItem%s_%s"
|
|
|
|
+ query := "select distinct `source` from participate_push_statistics where "
|
|
|
|
+ // 个人用户
|
|
|
|
+ if entId == 0 {
|
|
|
|
+ // 查职位id
|
|
|
|
+ query += fmt.Sprintf(" position_id =%d", positionId)
|
|
|
|
+ redisKey = fmt.Sprintf(redisKey, "personal", positionId)
|
|
|
|
+ } else {
|
|
|
|
+ // 企业用户 用企业id查
|
|
|
|
+ query += fmt.Sprintf(" end =%d", entId)
|
|
|
|
+ redisKey = fmt.Sprintf(redisKey, "ent", entId)
|
|
|
|
+ }
|
|
|
|
+ if data, err := redis.GetBytes("other", redisKey); err == nil && data != nil {
|
|
|
|
+ err := json.Unmarshal(*data, &result)
|
|
|
|
+ if err == nil {
|
|
|
|
+ return result
|
|
|
|
+ } else {
|
|
|
|
+ log.Println("序列化失败", redisKey, err)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //
|
|
|
|
+ rs := IC.BaseMysql.SelectBySql(query)
|
|
|
|
+ if rs == nil || len(*rs) == 0 {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ for i := 0; i < len(*rs); i++ {
|
|
|
|
+ value := common.IntAll((*rs)[i][""])
|
|
|
|
+ if name, ok := SelectItemMap[value]; ok {
|
|
|
|
+ result = append(result, &bxcore.SourceItem{
|
|
|
|
+ Name: name,
|
|
|
|
+ Value: int64(value),
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if len(result) > 0 {
|
|
|
|
+ // todo 存缓存
|
|
|
|
+ rsByte, _ := json.Marshal(result)
|
|
|
|
+ redis.PutBytes("other", redisKey, &rsByte, 60*60*2)
|
|
|
|
+ }
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
func (in *ParticipateStatistics) PersonHandle(entUserIdArr []string) (isAdmin bool, idStr string, users *[]map[string]interface{}) {
|
|
func (in *ParticipateStatistics) PersonHandle(entUserIdArr []string) (isAdmin bool, idStr string, users *[]map[string]interface{}) {
|
|
userEnt := EntInfo(common.IntAll(in.EntId), common.IntAll(in.EntUserId))
|
|
userEnt := EntInfo(common.IntAll(in.EntId), common.IntAll(in.EntUserId))
|
|
if len(entUserIdArr) > 0 {
|
|
if len(entUserIdArr) > 0 {
|
|
@@ -247,6 +302,7 @@ func ProjectHandle(data *[]map[string]interface{}, users *[]map[string]interface
|
|
for _, v := range *result {
|
|
for _, v := range *result {
|
|
personName := strings.Split(v.PersonName, "_")[0]
|
|
personName := strings.Split(v.PersonName, "_")[0]
|
|
k := common.Int64All(strings.Split(v.PersonName, "_")[1])
|
|
k := common.Int64All(strings.Split(v.PersonName, "_")[1])
|
|
|
|
+ a, _ := json.Marshal("balll")
|
|
projectStatisticsList[k] = &bxcore.ProjectStatisticsData{
|
|
projectStatisticsList[k] = &bxcore.ProjectStatisticsData{
|
|
PersonName: personName,
|
|
PersonName: personName,
|
|
DepartmentName: v.DepartmentName,
|
|
DepartmentName: v.DepartmentName,
|
|
@@ -259,6 +315,7 @@ func ProjectHandle(data *[]map[string]interface{}, users *[]map[string]interface
|
|
ChannelWinNumb: common.Int64All(len(v.ChannelWinNumb)),
|
|
ChannelWinNumb: common.Int64All(len(v.ChannelWinNumb)),
|
|
NotBidNumber: common.Int64All(len(v.NotBidNumber)),
|
|
NotBidNumber: common.Int64All(len(v.NotBidNumber)),
|
|
EndNumb: common.Int64All(len(v.EndNumb)),
|
|
EndNumb: common.Int64All(len(v.EndNumb)),
|
|
|
|
+ Stage: &anypb.Any{Value: a},
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return projectStatisticsList
|
|
return projectStatisticsList
|
|
@@ -385,7 +442,7 @@ func DataHanle(data map[string]interface{}, project_id string) map[string]interf
|
|
}
|
|
}
|
|
return data
|
|
return data
|
|
}
|
|
}
|
|
-func QueryHandle(isAdmin bool, startTime, endTime int64, personArrStr string, source int64, bidWay int64) []string {
|
|
|
|
|
|
+func QueryHandle(isAdmin bool, startTime, endTime int64, personArrStr string, source []int64, bidWay int64) []string {
|
|
//时间处理
|
|
//时间处理
|
|
query := []string{}
|
|
query := []string{}
|
|
if isAdmin {
|
|
if isAdmin {
|
|
@@ -406,10 +463,15 @@ func QueryHandle(isAdmin bool, startTime, endTime int64, personArrStr string, so
|
|
if endTime != 0 {
|
|
if endTime != 0 {
|
|
query = append(query, fmt.Sprintf(" ymd <= %d ", endTime))
|
|
query = append(query, fmt.Sprintf(" ymd <= %d ", endTime))
|
|
}
|
|
}
|
|
- if source != -1 {
|
|
|
|
- query = append(query, fmt.Sprintf("source = %d", source))
|
|
|
|
|
|
+ if len(source) > 0 {
|
|
|
|
+ sourceValue := ""
|
|
|
|
+ for i := 0; i < len(source); i++ {
|
|
|
|
+ sourceValue += fmt.Sprint(source[i]) + ","
|
|
|
|
+ }
|
|
|
|
+ sourceValue = sourceValue[:len(sourceValue)-1]
|
|
|
|
+ query = append(query, fmt.Sprintf("source in ( %s )", sourceValue))
|
|
}
|
|
}
|
|
- if bidWay != -1 {
|
|
|
|
|
|
+ if bidWay != 0 {
|
|
query = append(query, fmt.Sprintf("bid_way = %d", bidWay))
|
|
query = append(query, fmt.Sprintf("bid_way = %d", bidWay))
|
|
}
|
|
}
|
|
return query
|
|
return query
|