Parcourir la source

feat:中标企业加密

wangshan il y a 1 an
Parent
commit
d3d8e5e368

+ 6 - 0
internal/dao/internal/analyzeTask.go

@@ -99,6 +99,12 @@ func (a *AnalyzeTask) Run() {
 				if err := json.Unmarshal(hit.Source, p); err == nil {
 					for uk, ui := range a.UI {
 						if ui.FormatParam.STime <= p.JgTime && ui.FormatParam.ETime >= p.JgTime {
+							if p.Entidlist == nil {
+								p.Entidlist = []string{}
+							}
+							if p.Ids == nil {
+								p.Ids = []string{}
+							}
 							ui.Start()
 							ui.Push(p)
 							//每4000条数据查看一次 用户是否取消

+ 8 - 5
internal/dao/internal/userTask.go

@@ -21,11 +21,12 @@ import (
 
 // user 信息
 type UserTask struct {
-	MgoUserId            string                       //用户id
-	PositionId           int64                        //职位id
-	Phone                string                       //手机号
-	StartTime            int64                        //开始时间
-	EndTime              int64                        //结束时间
+	MgoUserId            string //用户id
+	PositionId           int64  //职位id
+	Phone                string //手机号
+	StartTime            int64  //开始时间
+	EndTime              int64  //结束时间
+	CalculateLock        sync.Mutex
 	IsEnd                bool                         //是否结束
 	IsCancel             bool                         //是否已取消
 	IsFalse              bool                         //是否离线分析成功
@@ -93,8 +94,10 @@ func (ut *UserTask) Run() {
 		case info := <-ut.PInfo:
 			//项目信息匹配
 			if ut.MatchConditions(info) {
+				ut.CalculateLock.Lock()
 				//模块计算
 				ut.Calculate(info)
+				ut.CalculateLock.Unlock()
 			}
 		case <-ut.Ticker.C:
 			//是否已取消

+ 4 - 2
utility/userTask.go

@@ -4,7 +4,6 @@ import (
 	"analyze/internal/consts"
 	"analyze/internal/model"
 	"analyze/internal/model/entity"
-	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/encrypt"
 	"fmt"
 	"github.com/gogf/gf/v2/database/gredis"
@@ -194,7 +193,10 @@ func EncodeId(sid string) string {
 func UpdateWinnerInfoOfScore(key string, pt *entity.ProjectInfo, score float64) {
 	if pt.Winners != "" {
 		for k, w := range strings.Split(pt.Winners, ",") {
-			id := common.If(len(pt.Entidlist) > k, encrypt.EncodeArticleId2ByCheck(pt.Entidlist[k]), "").(string)
+			id := ""
+			if len(pt.Entidlist) > k {
+				id = encrypt.EncodeArticleId2ByCheck(pt.Entidlist[k])
+			}
 			UpdateIncrementRedis(key, fmt.Sprintf("%s##%s", w, id), score)
 		}
 	}