Ver Fonte

feat:结构保存

wangshan há 1 ano atrás
pai
commit
fd60a243dd

+ 19 - 14
internal/consts/consts.go

@@ -1,20 +1,25 @@
 package consts
 
 const (
-	JudgmentPrev0  = iota //地区分布-省份
-	JudgmentPrev1         //地区分布-城市
-	JudgmentPrev2         //客户分布
-	JudgmentPrev3         //项目数量TOP3客户类型的重点中标单位
-	JudgmentPrev4         //项目规模分布-金额分布
-	JudgmentPrev5         //项目数量-项目金额---TOP3地区的重点中标单位
-	JudgmentPrev6         //订阅分类|重点中标单位-项目数量|重点中标单位-项目金额
-	JudgmentPrev7         //采购单位--TOP30
-	JudgmentPrev8         //采购规模分布-金额分布
-	JudgmentPrev9         //中标单位--TOP30
-	JudgmentPrev10        //中标规模分布-金额分布
-	Top3           = 3
-	Top10          = 10
-	Top30          = 30
+	JudgmentPrev0        = iota //地区分布-省份
+	JudgmentPrev1               //地区分布-城市
+	JudgmentPrev2               //客户分布
+	JudgmentPrev3               //项目数量TOP3客户类型的重点中标单位
+	JudgmentPrev4               //项目规模分布-金额分布
+	JudgmentPrev5               //项目数量-项目金额---TOP3地区的重点中标单位
+	JudgmentPrev6               //订阅分类|重点中标单位-项目数量|重点中标单位-项目金额
+	JudgmentPrev7               //采购单位--TOP30
+	JudgmentPrev8               //采购规模分布-金额分布
+	JudgmentPrev9               //中标单位--TOP30
+	JudgmentPrev10              //中标规模分布-金额分布
+	Top3                 = 3
+	Top10                = 10
+	Top30                = 30
+	MarketScaleMain      = "marketanalysisreport_scal"
+	MarketTopProject     = "marketanalysisreport_top"
+	MarketProjectAllData = "marketanalysisreport_all"
+	MarketScaleRefine    = "marketanalysisreport_refine"
+	MarketBuyerAndWinner = "marketanalysisreport_bw"
 )
 
 var (

+ 50 - 1
internal/dao/internal/userTask.go

@@ -2,6 +2,8 @@ package internal
 
 import (
 	"analyze/internal/consts"
+	"analyze/internal/model"
+	"analyze/internal/model/do"
 	"analyze/internal/model/entity"
 	"analyze/utility"
 	"app.yhyue.com/moapp/jybase/common"
@@ -1308,7 +1310,54 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
 }
 
 // ResultSave  结果保存
-func (ut *UserTask) ResultSave() {}
+func (ut *UserTask) ResultSave() {
+	//市场概况+时间分布
+	scale := ut.Result.Scale
+	if scale.MarketProfile.ProjectCount > 0 {
+		var scaleMap = common.StructToMapMore(scale)
+		scaleMap["s_m_id"] = ut.Id
+		delete(scaleMap, "project_info_all")
+		if id := do.Mgo.Save(consts.MarketScaleMain, scaleMap); id == "" {
+			g.Log().Info(model.Ctx, fmt.Sprintf("marketanalysisreport -- 保存失败-:%s , %s", consts.MarketScaleMain, ut.Id))
+		}
+	}
+	//项目规模TOP10 集合
+	topProject := ut.Result.TopProject
+	if len(topProject.ProjectTop10) > 0 {
+		var topProject10 = common.StructToMapMore(topProject.ProjectTop10)
+		topProject10["s_m_id"] = ut.Id
+		if id := do.Mgo.Save(consts.MarketTopProject, topProject10); id == "" {
+			g.Log().Info(model.Ctx, fmt.Sprintf("marketanalysisreport -- 保存失败-:%s , %s", consts.MarketTopProject, ut.Id))
+		}
+	}
+	///* 项目规模 地区分布 客户分布 地区客户top3*/
+	pad := ut.Result.ProjectAllData
+	if len(pad.ProjectScale) > 0 {
+		var padMap = common.StructToMapMore(pad)
+		padMap["s_m_id"] = ut.Id
+		if id := do.Mgo.Save(consts.MarketProjectAllData, padMap); id == "" {
+			g.Log().Info(model.Ctx, fmt.Sprintf("marketanalysisreport -- 保存失败-:%s , %s", consts.MarketProjectAllData, ut.Id))
+		}
+	}
+	//细化市场
+	sr := ut.Result.ScaleRefine
+	if len(sr.ScaleRefineAll) > 0 {
+		var srMap = common.StructToMapMore(sr)
+		srMap["s_m_id"] = ut.Id
+		if id := do.Mgo.Save(consts.MarketScaleRefine, srMap); id == "" {
+			g.Log().Info(model.Ctx, fmt.Sprintf("marketanalysisreport -- 保存失败-:%s , %s", consts.MarketScaleRefine, ut.Id))
+		}
+	}
+	///* 市场-采购单位&&中标企业*/
+	baw := ut.Result.BuyerAndWinner
+	if len(baw.WinnerCountTop3) > 0 {
+		var bawMap = common.StructToMapMore(baw)
+		bawMap["s_m_id"] = ut.Id
+		if id := do.Mgo.Save(consts.MarketBuyerAndWinner, bawMap); id == "" {
+			g.Log().Info(model.Ctx, fmt.Sprintf("marketanalysisreport -- 保存失败-:%s , %s", consts.MarketBuyerAndWinner, ut.Id))
+		}
+	}
+}
 
 // ForMatData 获取格式化请求参数
 func (ut *UserTask) ForMatData() error {

+ 2 - 2
internal/model/entity/result.go

@@ -86,10 +86,10 @@ type CustomerScaleS struct {
 // 项目规模分布
 type ProjectScaleS struct {
 	Name     string  `json:"Name"`      //项目规模名称
-	PersentC float64 `json:"Persent_c"` //项目总金额占比
-	PersentA float64 `json:"Persent_a"` //项目总数占比
 	Count    int     `json:"count"`     //项目总数--del--
 	Amount   float64 `json:"amount"`    //总金额--del--
+	PersentC float64 `json:"Persent_c"` //项目总金额占比
+	PersentA float64 `json:"Persent_a"` //项目总数占比
 }
 
 // 中标单位信息-金额