浏览代码

增加项目id、过滤中国移动网数据、生成Excel表格

jiaojiao7 4 年之前
父节点
当前提交
e99f023307

+ 7 - 2
src/config.json

@@ -68,7 +68,8 @@
     "project_appid": [
 		"111",
 		"222",
-		"jyPB1XQgsGBQNbQElICQNW"
+		"jyPB1XQgsGBQNbQElICQNW",
+		"jyMDBXQQIDCQBeSUdBITNf"
 	],
 	"s_winner_filter": [",", "//", "、", ";", ";", "#_#", "(01包)", "(02包)", "(1)", "(12)", "(1包)", "(A)", "(A包)",
 		"(按综合评分法排列名次)", "(包1)", "(包5)", "(包二)", "(包件1)", "(包件2)", "(包件一)", "(包三)", "(包四)", "(包一)",
@@ -86,11 +87,15 @@
 	"filetext_appid": [
 		"111",
 		"222",
-		"jyPB1XQgsGBQNbQElICQNW"
+		"jyPB1XQgsGBQNbQElICQNW",
+		"jyMDBXQQIDCQBeSUdBITNf"
 	],
 	"checkbidopen_appid": [
 		"111",
 		"222",
 		"jyPB1XQgsGBQNbQElICQNW"
+	],
+	"checkbidhref_appid": [
+		"jyMDBXQQIDCQBeSUdBITNf"
 	]
 }

+ 1 - 0
src/history/datamodel.go

@@ -78,6 +78,7 @@ var (
 	projectIdMap         = sync.Map{}
 	FileTextAppidMap     = map[string]bool{}
 	CheckBidOpenAppidMap = map[string]bool{}
+	CheckBidHrefAppidMap = map[string]bool{}
 )
 
 //客户模型

+ 9 - 5
src/history/historytask.go

@@ -41,10 +41,14 @@ func (this *HistoryData) HistoryTask(history_id string) {
 		email := qu.ObjToString(c["sendMail"])       //推送邮箱
 		isDup := qu.IntAll(c["isDup"])               //是否去重
 		isfile := false
+		isHenanMobile := false
 		if FileTextAppidMap[appId] {
 			isfile = true
 		}
-
+		if CheckBidHrefAppidMap[appId] {
+			isHenanMobile = true
+		}
+		log.Println(isfile, isHenanMobile)
 		cus := &Customer{}
 		cus.SaveDataMap = map[string]map[string]interface{}{}
 		cus.SaveDataArr = []map[string]interface{}{}
@@ -85,9 +89,9 @@ func (this *HistoryData) HistoryTask(history_id string) {
 		cus.GetTagRules(tag_rules)               //获取客户打标签规则
 		cus.GetDepartments("history", dep_rules) //获取客户信息
 		qu.Debug("customer:", cus.ID, cus.Name, cus.PushModel, cus.AppId, cus.IsTagRule, cus.IsSearchHosp, cus.IsSearchEnps, len(cus.TagRules), len(cus.Departments))
-		cus.GetData("history")                     //获取数据
-		cus.RemoveRepeatData()                     //数据去重
-		cus.AssembelAndSaveData(history_id, isDup,isFilter) //组装、保存数据
+		cus.GetData("history")                               //获取数据
+		cus.RemoveRepeatData()                               //数据去重
+		cus.AssembelAndSaveData(history_id, isDup, isFilter) //组装、保存数据
 		//发邮件
 		go func() {
 			time.Sleep(3 * time.Second)
@@ -96,7 +100,7 @@ func (this *HistoryData) HistoryTask(history_id string) {
 			if len(xlsxArr) != xlsxCount {
 				log.Println("excel数据量错误")
 			}
-			GetXlsxs(xlsxArr, customer_name, email, history_id, isfile)
+			GetXlsxs(xlsxArr, customer_name, email, history_id, isfile, isHenanMobile)
 			go UpdateHistoryState(2, history_id, xlsxCount)
 			xlsxArr = []map[string]interface{}{}
 			xlsxCount = 0

+ 7 - 0
src/history/task.go

@@ -164,6 +164,13 @@ func (c *Customer) GetData(stype string) {
 										}
 									}
 								}
+								//河南移动,过滤掉中国移动采购网招标数据
+								if CheckBidHrefAppidMap[c.AppId] {
+									if strings.Contains(qu.ObjToString(tmp["href"]), "b2b.10086.cn") {
+										qu.Debug("跳过该条数据,公告原网址中包含 b2b.10086.cn,", id)
+										return
+									}
+								}
 								//
 								tmp["id"] = id //记录数据原有id
 								delete(tmp, "_id")

+ 69 - 1
src/history/util_history.go

@@ -485,6 +485,14 @@ func AssembelSave(tmp map[string]interface{}, IsSearchHosp, IsSearchEnps bool, h
 			}
 		}
 	}
+	//河南移动
+	if CheckBidHrefAppidMap[appid] {
+		projectId := GetProjectId(id)
+		if projectId != "" {
+			//projectIds := strings.Split(projectId, ",")
+			tmp["projectId"] = projectId
+		}
+	}
 	if isDup == 1 {
 		ok := checkBidId(appid, id)
 		if !ok {
@@ -821,7 +829,7 @@ func SkipData(tmp map[string]interface{}) bool {
 	return false
 }
 
-func GetXlsxs(mMap []map[string]interface{}, fn, email, id string, isfile bool) {
+func GetXlsxs(mMap []map[string]interface{}, fn, email, id string, isfile, isHenanMobile bool) {
 	if id != "" {
 		query := bson.M{
 			"_id": bson.ObjectIdHex(id),
@@ -1036,6 +1044,66 @@ func GetXlsxs(mMap []map[string]interface{}, fn, email, id string, isfile bool)
 					row.AddCell().SetValue(ids)
 				}
 				xf.Sheets = xf.Sheets[3:4]
+			} else if dataType == 5 {
+				sh := xf.Sheets[4]
+				//if isfile {
+				//	cell := sh.Rows[0].AddCell()
+				//	cell.SetValue("附件")
+				//	cell.SetStyle(style)
+				//}
+				for _, v := range mMap {
+					row := sh.AddRow()
+					// row.AddCell().SetInt(i + 1)
+					row.AddCell().SetValue(v["matchkey"]) //信息匹配词
+					row.AddCell().SetValue(v["city"])        //城市
+					row.AddCell().SetValue(v["district"])    //县区
+					row.AddCell().SetValue(v["projectname"]) //项目名称
+					row.AddCell().SetValue(v["buyer"])       //采购单位
+					row.AddCell().SetValue(v[""])            //采购单位类别---私有标签tagname
+					if v["bidamount"] != nil { //中标金额
+						row.AddCell().SetFloat(qu.Float64All(v["bidamount"]))
+					} else {
+						row.AddCell()
+					}
+					if v["budget"] != nil { //预算
+						row.AddCell().SetFloat(qu.Float64All(v["budget"]))
+					} else {
+						row.AddCell()
+					}
+					if v["publishtime"] != nil { //公告发布时间
+						row.AddCell().SetValue(time.Unix(qu.Int64All(v["publishtime"]), 0).Format("2006-01-02"))
+					} else {
+						row.AddCell()
+					}
+					if v["bidopentime"] != nil { //开标日期
+						row.AddCell().SetValue(time.Unix(qu.Int64All(v["bidopentime"]), 0).Format("2006-01-02"))
+					} else {
+						row.AddCell()
+					}
+					row.AddCell().SetValue(v["s_winner"])           //中标单位
+					row.AddCell().SetValue(v[""])                   //中标模式--移动、电信、联通
+					row.AddCell().SetValue(v["title"])              //公告标题
+					row.AddCell().SetValue(v["subtype"])            //公告类别
+					row.AddCell().SetValue(v["area"])               //省份
+					row.AddCell().SetValue(v["projectscope"])       //项目范围
+					row.AddCell().SetValue(v["agency"])             //招标代理机构
+					row.AddCell().SetValue(v["detail"])             //公告内容
+					row.AddCell().SetValue(v["href"])               //公告地址
+					row.AddCell().SetValue(v["buyerperson"])        //采购单位联系人
+					row.AddCell().SetValue(v["buyertel"])           //采购单位联系电话
+					row.AddCell().SetValue(v["winnerperson"])       //中标单位联系人
+					row.AddCell().SetValue(v["winnertel"])          //中标单位联系电话
+					row.AddCell().SetValue(v["legal_person"])       //中标企业联系人
+					row.AddCell().SetValue(v["company_phone"])      //中标企业联系电话
+					row.AddCell().SetValue(v["company_email"])      //中标企业邮箱
+					ids := SE.EncodeString(qu.ObjToString(v["id"])) //唯一标识
+					row.AddCell().SetValue(ids)
+					row.AddCell().SetValue(SE.EncodeString(qu.ObjToString(v["projectId"]))) //项目标识
+
+					//row.AddCell().SetValue(v["jybxhref"])
+					//row.AddCell().SetValue(v["projectcode"])
+				}
+				xf.Sheets = xf.Sheets[4:5]
 			}
 			xf.Sheets[0].Name = "详细数据"
 			//生文件

+ 3 - 0
src/main.go

@@ -68,6 +68,9 @@ func init() {
 	for _, s := range util.Sysconfig["checkbidopen_appid"].([]interface{}) {
 		history.CheckBidOpenAppidMap[s.(string)] = true
 	}
+	for _, v := range util.Sysconfig["checkbidhref_appid"].([]interface{}) {
+		history.CheckBidHrefAppidMap[v.(string)] = true
+	}
 }
 
 func main() {

+ 55 - 1
src/service/second_push.go

@@ -35,7 +35,6 @@ type SecondPush struct {
 	secondPushList    xweb.Mapper `xweb:"/service/secondpush/list"`
 	secondPushClone   xweb.Mapper `xweb:"/service/secondPushClone/(.*)"`
 	delSecondPushRule xweb.Mapper `xweb:"/service/customer/secondpush/delrule"` //删除历史任务规则
-
 }
 
 func (s *SecondPush) SecondPush() {
@@ -571,6 +570,61 @@ func GetXlsxs(mMap []map[string]interface{}, fn, email, id string) {
 					row.AddCell().SetValue(ids)
 				}
 				xf.Sheets = xf.Sheets[3:4]
+			} else if dataType == 5 {
+				sh := xf.Sheets[4]
+				for _, v := range mMap {
+					row := sh.AddRow()
+					// row.AddCell().SetInt(i + 1)
+					row.AddCell().SetValue(v["matchkey"])    //信息匹配词
+					row.AddCell().SetValue(v["city"])        //城市
+					row.AddCell().SetValue(v["district"])    //县区
+					row.AddCell().SetValue(v["projectname"]) //项目名称
+					row.AddCell().SetValue(v["buyer"])       //采购单位
+					row.AddCell().SetValue(v["tagname"])     //采购单位类别---私有标签tagname
+					if v["bidamount"] != nil { //中标金额
+						row.AddCell().SetFloat(qu.Float64All(v["bidamount"]))
+					} else {
+						row.AddCell()
+					}
+					if v["budget"] != nil { //预算
+						row.AddCell().SetFloat(qu.Float64All(v["budget"]))
+					} else {
+						row.AddCell()
+					}
+					if v["publishtime"] != nil { //公告发布时间
+						row.AddCell().SetValue(time.Unix(qu.Int64All(v["publishtime"]), 0).Format("2006-01-02"))
+					} else {
+						row.AddCell()
+					}
+					if v["bidopentime"] != nil { //开标日期
+						row.AddCell().SetValue(time.Unix(qu.Int64All(v["bidopentime"]), 0).Format("2006-01-02"))
+					} else {
+						row.AddCell()
+					}
+					row.AddCell().SetValue(v["s_winner"])           //中标单位
+					row.AddCell().SetValue(v[""])                   //中标模式--移动、电信、联通
+					row.AddCell().SetValue(v["title"])              //公告标题
+					row.AddCell().SetValue(v["subtype"])            //公告类别
+					row.AddCell().SetValue(v["area"])               //省份
+					row.AddCell().SetValue(v["projectscope"])       //项目范围
+					row.AddCell().SetValue(v["agency"])             //招标代理机构
+					row.AddCell().SetValue(v["detail"])             //公告内容
+					row.AddCell().SetValue(v["href"])               //公告地址
+					row.AddCell().SetValue(v["buyerperson"])        //采购单位联系人
+					row.AddCell().SetValue(v["buyertel"])           //采购单位联系电话
+					row.AddCell().SetValue(v["winnerperson"])       //中标单位联系人
+					row.AddCell().SetValue(v["winnertel"])          //中标单位联系电话
+					row.AddCell().SetValue(v["legal_person"])       //中标企业联系人
+					row.AddCell().SetValue(v["company_phone"])      //中标企业联系电话
+					row.AddCell().SetValue(v["company_email"])      //中标企业邮箱
+					ids := SE.EncodeString(qu.ObjToString(v["id"])) //唯一标识
+					row.AddCell().SetValue(ids)
+					row.AddCell().SetValue(v["projectId"]) //项目标识
+
+					//row.AddCell().SetValue(v["jybxhref"])
+					//row.AddCell().SetValue(v["projectcode"])
+				}
+				xf.Sheets = xf.Sheets[4:5]
 			}
 			xf.Sheets[0].Name = "详细数据"
 			//生文件

二进制
src/web/res/fields.xlsx


二进制
src/web/res/xlsx/1604548112/1604548112.xlsx


二进制
src/web/res/xlsx/1604553386/1604553386.xlsx


二进制
src/web/res/xlsx/1604646373/1604646373.xlsx


二进制
src/web/res/xlsx/1604647004/1604647004.xlsx


二进制
src/web/res/xlsx/1604647163/1604647163.xlsx


+ 1 - 0
src/web/templates/private/customer_history.html

@@ -116,6 +116,7 @@
                                                         <option value="1">标准字段包</option>
                                                         <option value="3">深信服字段包</option>
                                                         <option value="4">高级字段包+部门名称+规则名称</option>
+                                                        <option value="5">河南移动字段包</option>
                                                     </select>
                                                     <script>
                                                         $('#extfiledselect').on("change", function () {

+ 1 - 0
src/web/templates/private/second_push_create.html

@@ -68,6 +68,7 @@
                                                         <option value="1">标准字段包</option>
                                                         <option value="3">深信服字段包</option>
                                                         <option value="4">高级字段包+部门名称+规则名称</option>
+                                                        <option value="5">河南移动字段包</option>
                                                     </select>
                                                 </div>
                                             </div>