|
@@ -31,17 +31,18 @@ const (
|
|
|
ReportCanceledKey = "marketAnalysisCanceled_%s" // 取消的报告id
|
|
|
ReportCanceledTime = 60 * 60 * 24
|
|
|
|
|
|
- ReportStateGenerating = 0 // 报告生成状态 生成中
|
|
|
- ReportStateGenerated = 1 // 生成 成功
|
|
|
- ReportStateCanceled = 2 // 已取消
|
|
|
- ReportStateFailed = -1 // 生成失败
|
|
|
- CollMarketScaleMain = "marketanalysisreport_scal" //市场规模 报告模块对应的mongo 集合名称
|
|
|
- CollMarketTopProject = "marketanalysisreport_top" //项目规模TOP10
|
|
|
- CollMarketProjectAllData = "marketanalysisreport_all" //项目规模 地区分布 客户分布 地区客户top3
|
|
|
- CollMarketScaleRefine = "marketanalysisreport_refine" //细化市场
|
|
|
- CollMarketBuyerAndWinner = "marketanalysisreport_bw" //市场-采购单位&&中标企业
|
|
|
- ValueOffline = 1 // 离线
|
|
|
- ValueRealTime = 2 // 实时
|
|
|
+ ReportStateGenerating = 0 // 报告生成状态 生成中
|
|
|
+ ReportStateGenerated = 1 // 生成 成功
|
|
|
+ ReportStateCanceled = 2 // 已取消
|
|
|
+ ReportStateFailed = -1 // 生成失败
|
|
|
+ CollMarketScaleMain = "marketanalysisreport_scal" //市场规模 报告模块对应的mongo 集合名称
|
|
|
+ CollMarketTopProject = "marketanalysisreport_top" //项目规模TOP10
|
|
|
+ CollMarketProjectAllData = "marketanalysisreport_all" //项目规模 地区分布 客户分布 地区客户top3
|
|
|
+ CollMarketScaleRefine = "marketanalysisreport_refine" //细化市场
|
|
|
+ CollMarketBuyerAndWinner = "marketanalysisreport_bw" //市场-采购单位&&中标企业
|
|
|
+ ValueOffline = 1 // 离线
|
|
|
+ ValueRealTime = 2 // 实时
|
|
|
+ Tablejianyu_mar_user_account = "jianyu.mar_user_account" // 离线市场报告分析关键词标准信息表
|
|
|
)
|
|
|
|
|
|
var MarketAnalysisPool chan bool
|
|
@@ -140,6 +141,24 @@ func (mae *MarketAnalysisEntity) ForMatData() error {
|
|
|
if mae.FormatParam.KeysItems == nil || len(mae.FormatParam.KeysItems) == 0 {
|
|
|
return fmt.Errorf("请选择关键词组")
|
|
|
}
|
|
|
+ var flag bool
|
|
|
+ // 判断关键词是不是为空
|
|
|
+ for i := 0; i < len(mae.FormatParam.KeysItems); i++ {
|
|
|
+ items := mae.FormatParam.KeysItems[i]
|
|
|
+ for j := 0; j < len(items.A_Key); j++ {
|
|
|
+ AKey := items.A_Key[j]
|
|
|
+ if len(AKey.Keyword) > 0 {
|
|
|
+ flag = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if flag {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if !flag {
|
|
|
+ return fmt.Errorf("请选择关键词组")
|
|
|
+ }
|
|
|
//格式化时间段
|
|
|
if timeArr := strings.Split(mae.BaseParam.RangeTime, "-"); len(timeArr) == 2 {
|
|
|
mae.FormatParam.STime = qutil.Int64All(timeArr[0])
|
|
@@ -559,9 +578,18 @@ func (mae *MarketAnalysisEntity) IsOffline() (offline bool) {
|
|
|
}
|
|
|
}
|
|
|
if keyCount > config.Config.MarketAnalysisPool.KeyWordsCount {
|
|
|
- mae.Offline = ValueOffline
|
|
|
- return true
|
|
|
+ // 查询配置
|
|
|
+ if mac := mae.getMarUserAccount(); mac != nil {
|
|
|
+ if keyCount >= mac.Threshold {
|
|
|
+ mae.Offline = ValueOffline
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ mae.Offline = ValueOffline
|
|
|
+ return true
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
// 查询数据量
|
|
|
countSql := fmt.Sprintf(mae.GetCommonQuerySql(), "")
|
|
|
log.Println("IsOffline count SQL:", countSql)
|
|
@@ -578,6 +606,19 @@ func (mae *MarketAnalysisEntity) IsOffline() (offline bool) {
|
|
|
mae.Offline = ValueRealTime
|
|
|
return false
|
|
|
}
|
|
|
+
|
|
|
+type MarUserAccount struct {
|
|
|
+ Threshold int // 关键词离线标准量
|
|
|
+}
|
|
|
+
|
|
|
+// 获取离线市场报告分析关键词标准信息
|
|
|
+func (mae *MarketAnalysisEntity) getMarUserAccount() *MarUserAccount {
|
|
|
+ rs := db.Mysql.SelectBySql(fmt.Sprintf("SELECT threshold FROM %s where position_id=? and state = 0;", Tablejianyu_mar_user_account), mae.PositionId)
|
|
|
+ if rs != nil && len(*rs) > 0 {
|
|
|
+ return &MarUserAccount{Threshold: qutil.IntAll((*rs)[0]["threshold"])}
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
func (mae *MarketAnalysisEntity) GetReportState() (generated bool, needUpdate bool, err error) {
|
|
|
// 查库
|
|
|
err = mae.GetAnalysisFromMgoDb()
|