|
@@ -7,6 +7,7 @@ import (
|
|
"app.yhyue.com/moapp/jybase/mongodb"
|
|
"app.yhyue.com/moapp/jybase/mongodb"
|
|
"app.yhyue.com/moapp/jybase/redis"
|
|
"app.yhyue.com/moapp/jybase/redis"
|
|
"encoding/json"
|
|
"encoding/json"
|
|
|
|
+ "errors"
|
|
"fmt"
|
|
"fmt"
|
|
"jy/src/jfw/modules/bigmember/src/config"
|
|
"jy/src/jfw/modules/bigmember/src/config"
|
|
"jy/src/jfw/modules/bigmember/src/db"
|
|
"jy/src/jfw/modules/bigmember/src/db"
|
|
@@ -45,7 +46,9 @@ const (
|
|
Tablejianyu_mar_user_account = "jianyu.mar_user_account" // 离线市场报告分析关键词标准信息表
|
|
Tablejianyu_mar_user_account = "jianyu.mar_user_account" // 离线市场报告分析关键词标准信息表
|
|
)
|
|
)
|
|
|
|
|
|
-var MarketAnalysisPool chan bool
|
|
|
|
|
|
+var (
|
|
|
|
+ MarketAnalysisPool chan bool
|
|
|
|
+)
|
|
|
|
|
|
func init() {
|
|
func init() {
|
|
MarketAnalysisPool = make(chan bool, config.Config.MarketAnalysisPool.Limit)
|
|
MarketAnalysisPool = make(chan bool, config.Config.MarketAnalysisPool.Limit)
|
|
@@ -111,6 +114,7 @@ type MarketAnalysisEntity struct {
|
|
Phone string // 手机号
|
|
Phone string // 手机号
|
|
PositionId int
|
|
PositionId int
|
|
OriginalTotal int64 // 数据总数
|
|
OriginalTotal int64 // 数据总数
|
|
|
|
+ Source string
|
|
}
|
|
}
|
|
|
|
|
|
type projectInfo struct {
|
|
type projectInfo struct {
|
|
@@ -222,6 +226,101 @@ func (mae *MarketAnalysisEntity) ForMatData() error {
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// ForMatData 获取格式化请求参数
|
|
|
|
+func (mae *MarketAnalysisEntity) ForMatDataPdf() error {
|
|
|
|
+ //格式化订阅词
|
|
|
|
+ if err := json.Unmarshal([]byte(mae.BaseParam.KeysItemsStr), &mae.FormatParam.KeysItems); err != nil {
|
|
|
|
+ return fmt.Errorf("关键词组格式异常")
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //格式化时间段
|
|
|
|
+ if timeArr := strings.Split(mae.BaseParam.RangeTime, "-"); len(timeArr) == 2 {
|
|
|
|
+ mae.FormatParam.STime = qutil.Int64All(timeArr[0])
|
|
|
|
+ mae.FormatParam.ETime = qutil.Int64All(timeArr[1])
|
|
|
|
+ if mae.FormatParam.STime == 0 || mae.FormatParam.ETime == 0 {
|
|
|
|
+ return fmt.Errorf("开始时间和结束时间不能为空")
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ return fmt.Errorf("时间戳格式异常")
|
|
|
|
+ }
|
|
|
|
+ //格式化省份、城市
|
|
|
|
+ if areaStr := strings.TrimSpace(mae.BaseParam.Area); areaStr != "" {
|
|
|
|
+ imap := map[string][]string{}
|
|
|
|
+ if err := json.Unmarshal([]byte(mae.BaseParam.Area), &imap); err != nil {
|
|
|
|
+ return fmt.Errorf("非法地区信息")
|
|
|
|
+ }
|
|
|
|
+ var city, area []string
|
|
|
|
+ for name, v := range imap {
|
|
|
|
+ if len(v) == 0 {
|
|
|
|
+ area = append(area, name)
|
|
|
|
+ } else {
|
|
|
|
+ for _, vv := range v {
|
|
|
|
+ city = append(city, vv)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ mae.FormatParam.Area = area
|
|
|
|
+ mae.FormatParam.City = city
|
|
|
|
+ }
|
|
|
|
+ //格式化行业
|
|
|
|
+ if industryStr := strings.TrimSpace(mae.BaseParam.Industry); industryStr != "" {
|
|
|
|
+ imap := map[string][]string{}
|
|
|
|
+ if err := json.Unmarshal([]byte(industryStr), &imap); err != nil {
|
|
|
|
+ return fmt.Errorf("非法行业信息")
|
|
|
|
+ }
|
|
|
|
+ var farr []string
|
|
|
|
+ for name, v := range imap {
|
|
|
|
+ for _, vv := range v {
|
|
|
|
+ farr = append(farr, fmt.Sprintf("%s_%s", name, vv))
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ mae.FormatParam.Industry = farr
|
|
|
|
+ }
|
|
|
|
+ //格式化类型
|
|
|
|
+ if buyerClassStr := strings.TrimSpace(mae.BaseParam.BuyerClass); buyerClassStr != "" {
|
|
|
|
+ mae.FormatParam.BuyerClass = strings.Split(buyerClassStr, ",")
|
|
|
|
+ }
|
|
|
|
+ //中标企业
|
|
|
|
+ mae.FormatParam.Winner = mae.BaseParam.Winner
|
|
|
|
+ //采购单位
|
|
|
|
+ mae.FormatParam.Buyer = mae.BaseParam.Buyer
|
|
|
|
+ //排序
|
|
|
|
+ mae.FormatParam.Sort = qutil.If(mae.BaseParam.Sort != 0 && mae.BaseParam.Sort != 1, 0, mae.BaseParam.Sort).(int)
|
|
|
|
+ if mae.BaseParam.PageNum*mae.BaseParam.PageSize > config.Config.ProjectCount {
|
|
|
|
+ mae.BaseParam.PageNum = config.Config.ProjectCount / mae.BaseParam.PageSize
|
|
|
|
+ }
|
|
|
|
+ //当前页码
|
|
|
|
+ mae.FormatParam.PageNum = qutil.If(mae.BaseParam.PageNum < 1 || mae.BaseParam.PageNum > 1000, 1, mae.BaseParam.PageNum).(int)
|
|
|
|
+ //默认每页10条
|
|
|
|
+ mae.FormatParam.PageSize = qutil.If(mae.BaseParam.PageSize < 1 || mae.BaseParam.PageSize > 100, 50, mae.BaseParam.PageSize).(int)
|
|
|
|
+ data := map[string]interface{}{
|
|
|
|
+ "s_keysItems": mae.BaseParam.KeysItemsStr,
|
|
|
|
+ "s_rangeTime": mae.BaseParam.RangeTime,
|
|
|
|
+ "s_rangeTimeExtra": mae.BaseParam.RangeTimeExtra,
|
|
|
|
+ "s_area": mae.BaseParam.Area,
|
|
|
|
+ "s_industry": mae.BaseParam.Industry,
|
|
|
|
+ "s_buyerClass": mae.BaseParam.BuyerClass,
|
|
|
|
+ "s_matchingMode": mae.BaseParam.MatchingMode,
|
|
|
|
+ "s_userId": mae.UId,
|
|
|
|
+ "s_parentId": mae.Pid,
|
|
|
|
+ "s_mgoUserId": mae.MgoUserId,
|
|
|
|
+ "i_positionId": mae.PositionId,
|
|
|
|
+ "s_phone": mae.Phone,
|
|
|
|
+ "audit": 1,
|
|
|
|
+ }
|
|
|
|
+ if mae.OriginalTotal > 0 {
|
|
|
|
+ data["l_originalTotal"] = mae.OriginalTotal
|
|
|
|
+ }
|
|
|
|
+ if mae.Source != "" {
|
|
|
|
+ data["source"] = mae.Source
|
|
|
|
+ }
|
|
|
|
+ rs, b := db.Mgo.FindOne(ReportHistoryTable, data)
|
|
|
|
+ if b && rs != nil && len(*rs) > 0 {
|
|
|
|
+ return errors.New("当期分析已存在")
|
|
|
|
+ }
|
|
|
|
+ return nil
|
|
|
|
+}
|
|
|
|
+
|
|
// GetProjectInfoList 项目明细
|
|
// GetProjectInfoList 项目明细
|
|
func (mae *MarketAnalysisEntity) GetProjectInfoList() error {
|
|
func (mae *MarketAnalysisEntity) GetProjectInfoList() error {
|
|
var (
|
|
var (
|
|
@@ -287,10 +386,10 @@ func (mae *MarketAnalysisEntity) SaveAnalysisRecord() error {
|
|
"s_matchingMode": mae.BaseParam.MatchingMode,
|
|
"s_matchingMode": mae.BaseParam.MatchingMode,
|
|
"s_userId": mae.UId,
|
|
"s_userId": mae.UId,
|
|
"s_parentId": mae.Pid,
|
|
"s_parentId": mae.Pid,
|
|
- "i_state": mae.State, //状态:默认0:生成中;1:已生成;2:已取消;-1:生成失败
|
|
|
|
|
|
+ "i_state": 1, //状态:默认0:生成中;1:已生成;2:已取消;-1:生成失败
|
|
"l_updateTime": time.Now().Unix(), //生成时间 or 取消时间
|
|
"l_updateTime": time.Now().Unix(), //生成时间 or 取消时间
|
|
"l_createTime": time.Now().Unix(),
|
|
"l_createTime": time.Now().Unix(),
|
|
- "i_offline": mae.Offline,
|
|
|
|
|
|
+ "i_offline": 2,
|
|
"s_mgoUserId": mae.MgoUserId,
|
|
"s_mgoUserId": mae.MgoUserId,
|
|
"i_positionId": mae.PositionId,
|
|
"i_positionId": mae.PositionId,
|
|
"s_phone": mae.Phone,
|
|
"s_phone": mae.Phone,
|
|
@@ -298,6 +397,9 @@ func (mae *MarketAnalysisEntity) SaveAnalysisRecord() error {
|
|
if mae.OriginalTotal > 0 {
|
|
if mae.OriginalTotal > 0 {
|
|
data["l_originalTotal"] = mae.OriginalTotal
|
|
data["l_originalTotal"] = mae.OriginalTotal
|
|
}
|
|
}
|
|
|
|
+ if mae.Source != "" {
|
|
|
|
+ data["source"] = mae.Source
|
|
|
|
+ }
|
|
mae.MgoRecordId = db.Mgo.Save(ReportHistoryTable, data)
|
|
mae.MgoRecordId = db.Mgo.Save(ReportHistoryTable, data)
|
|
if mae.MgoRecordId == "" {
|
|
if mae.MgoRecordId == "" {
|
|
return fmt.Errorf("分析创建异常")
|
|
return fmt.Errorf("分析创建异常")
|
|
@@ -402,6 +504,47 @@ func (mae *MarketAnalysisEntity) GetRecordList(pageNum, PageSize int) (total int
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func (mae *MarketAnalysisEntity) GetRecordPdfList(pageNum, PageSize int) (total int, list []map[string]interface{}) {
|
|
|
|
+ queryMap := map[string]interface{}{
|
|
|
|
+ "i_del": map[string]interface{}{"$ne": 1},
|
|
|
|
+ "source": "analysisPDF",
|
|
|
|
+ }
|
|
|
|
+ if mae.UId == mae.Pid { //主账号
|
|
|
|
+ queryMap["s_parentId"] = mae.Pid
|
|
|
|
+ } else {
|
|
|
|
+ queryMap["s_userId"] = mae.UId
|
|
|
|
+ }
|
|
|
|
+ if pageNum == 1 {
|
|
|
|
+ total = db.Mgo.Count(ReportHistoryTable, queryMap)
|
|
|
|
+ if total == 0 {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ total = -1
|
|
|
|
+ }
|
|
|
|
+ res, _ := db.Mgo.Find(ReportHistoryTable, queryMap, `{"l_createTime":-1}`, nil, false, (pageNum-1)*PageSize, PageSize)
|
|
|
|
+ if res == nil || len(*res) == 0 {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ for _, row := range *res {
|
|
|
|
+ data := map[string]interface{}{
|
|
|
|
+ "id": util.EncodeId(mongodb.BsonIdToSId(row["_id"])),
|
|
|
|
+ "keysItems": qutil.ObjToString(row["s_keysItems"]),
|
|
|
|
+ "area": qutil.ObjToString(row["s_area"]),
|
|
|
|
+ "industry": qutil.ObjToString(row["s_industry"]),
|
|
|
|
+ "buyerclass": qutil.ObjToString(row["s_buyerClass"]),
|
|
|
|
+ "rangeTime": qutil.ObjToString(row["s_rangeTime"]),
|
|
|
|
+ "s_rangeTimeExtra": qutil.ObjToString(row["s_rangeTimeExtra"]),
|
|
|
|
+ "createTime": qutil.Int64All(row["l_createTime"]),
|
|
|
|
+ "matchingMode": qutil.ObjToString(row["s_matchingMode"]), //项目匹配方式
|
|
|
|
+ "updateTime": qutil.Int64All(row["l_updateTime"]),
|
|
|
|
+ "audit": qutil.Int64All(row["audit"]),
|
|
|
|
+ }
|
|
|
|
+ list = append(list, data)
|
|
|
|
+ }
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
// GetQueryItem 获取查询条件,前端回显使用
|
|
// GetQueryItem 获取查询条件,前端回显使用
|
|
func (mae *MarketAnalysisEntity) getQueryItem() (map[string]interface{}, error) {
|
|
func (mae *MarketAnalysisEntity) getQueryItem() (map[string]interface{}, error) {
|
|
return map[string]interface{}{
|
|
return map[string]interface{}{
|