Explorar el Código

修改导出数据名称及二次推送拆分item

fuwencai hace 4 años
padre
commit
ea39622a0d
Se han modificado 2 ficheros con 280 adiciones y 244 borrados
  1. 275 240
      src/service/second_push.go
  2. 5 4
      src/util/parsxlsx.go

+ 275 - 240
src/service/second_push.go

@@ -234,7 +234,7 @@ func (s *SecondPush) SecondPushTask() {
 					for _, m := range c["dep_rules"].([]interface{}) {
 						log.Println("ruleid", mongoutil.BsonIdToSId(m.(map[string]interface{})["_id"]))
 						q := bson.M{
-							"ruleid":bson.M{"$regex": mongoutil.BsonIdToSId(m.(map[string]interface{})["_id"])},
+							"ruleid": bson.M{"$regex": mongoutil.BsonIdToSId(m.(map[string]interface{})["_id"])},
 							"bget":   1,
 							"createtime": bson.M{
 								"$gte": starttime,
@@ -244,7 +244,7 @@ func (s *SecondPush) SecondPushTask() {
 						d, _ := MgoCus.Find("usermail", q, nil, nil, false, 0, 0)
 						if len(*d) > 0 && d != nil {
 							for _, l := range *d {
-								if _,ok := idMap[l["_id"].(bson.ObjectId)];!ok{
+								if _, ok := idMap[l["_id"].(bson.ObjectId)]; !ok {
 									idMap[l["_id"].(bson.ObjectId)] = true
 									xlsxArr = append(xlsxArr, l)
 								}
@@ -405,279 +405,314 @@ func GetXlsxs(mMap []map[string]interface{}, fn, email, id string) {
 				for _, v := range mMap {
 					// 拿到所选字段包的sheet页  如果item存在则追加 不存在则创建新sheet页
 					var sheet *xlsx.Sheet
-					if v["item"].(string)==""{
+					if v["item"].(string) == "" {
 						v["item"] = "其他方式"
 					}
-					if _,ok :=newFile.Sheet[v["item"].(string)];ok{
-						sheet = newFile.Sheet[v["item"].(string)]
-						sheetIndex[v["item"].(string)] += 1
-					}else {
-						sheet ,err =newFile.AppendSheet(*sh,v["item"].(string))
-						sheetIndex[v["item"].(string)] = 1
-					}
-					row := sheet.AddRow()
-					row.AddCell().SetInt(sheetIndex[v["item"].(string)])
-					row.AddCell().SetValue(v["matchkey"])
-					row.AddCell().SetValue(v["area"])
-					row.AddCell().SetValue(v["city"])
-					row.AddCell().SetValue(v["title"])
-					row.AddCell().SetValue(v["subtype"])
-					if v["publishtime"] != nil {
-						row.AddCell().SetValue(time.Unix(qu.Int64All(v["publishtime"]), 0).Format("2006-01-02"))
-					} else {
-						row.AddCell()
-					}
-					row.AddCell().SetValue(v["buyer"])
-					row.AddCell().SetValue(v["s_winner"])
-					if v["bidamount"] != nil {
-						row.AddCell().SetFloat(qu.Float64All(v["bidamount"]))
-					} else {
-						row.AddCell()
+					items := strings.Split(v["item"].(string), ",")
+					for _, i := range items {
+						if len(items) > 1 {
+							v["matchkey"] = v["itemdist"].(map[string]interface{})[i]
+							v["item"] = i
+						}
+						if _, ok := newFile.Sheet[v["item"].(string)]; ok {
+							sheet = newFile.Sheet[v["item"].(string)]
+							sheetIndex[v["item"].(string)] += 1
+						} else {
+							sheet, err = newFile.AppendSheet(*sh, v["item"].(string))
+							sheetIndex[v["item"].(string)] = 1
+						}
+						row := sheet.AddRow()
+						row.AddCell().SetInt(sheetIndex[v["item"].(string)])
+						row.AddCell().SetValue(v["matchkey"])
+						row.AddCell().SetValue(v["area"])
+						row.AddCell().SetValue(v["city"])
+						row.AddCell().SetValue(v["title"])
+						row.AddCell().SetValue(v["subtype"])
+						if v["publishtime"] != nil {
+							row.AddCell().SetValue(time.Unix(qu.Int64All(v["publishtime"]), 0).Format("2006-01-02"))
+						} else {
+							row.AddCell()
+						}
+						row.AddCell().SetValue(v["buyer"])
+						row.AddCell().SetValue(v["s_winner"])
+						if v["bidamount"] != nil {
+							row.AddCell().SetFloat(qu.Float64All(v["bidamount"]))
+						} else {
+							row.AddCell()
+						}
+						row.AddCell().SetValue(v["projectname"])
+						row.AddCell().SetValue(v["detail"])
+						row.AddCell().SetValue(v["jybxhref"])
+						ids := SE.EncodeString(qu.ObjToString(v["id"]))
+						row.AddCell().SetValue(ids)
 					}
-					row.AddCell().SetValue(v["projectname"])
-					row.AddCell().SetValue(v["detail"])
-					row.AddCell().SetValue(v["jybxhref"])
-					ids := SE.EncodeString(qu.ObjToString(v["id"]))
-					row.AddCell().SetValue(ids)
+
 				}
 				//xf.Sheets = xf.Sheets[0:1]
 			} else if dataType == 2 {
 				sh := xf.Sheets[1]
 				for _, v := range mMap {
-					if v["item"].(string)==""{
+					if v["item"].(string) == "" {
 						v["item"] = "其他方式"
 					}
-					var sheet *xlsx.Sheet
-					if _,ok :=newFile.Sheet[v["item"].(string)];ok{
-						sheet = newFile.Sheet[v["item"].(string)]
-					}else {
-						sheet ,err =newFile.AppendSheet(*sh,v["item"].(string))
-					}
-					row := sheet.AddRow()
-					// row.AddCell().SetInt(i + 1)
-					row.AddCell().SetValue(v["matchkey"])
-					row.AddCell().SetValue(v["area"])
-					row.AddCell().SetValue(v["city"])
-					row.AddCell().SetValue(v["title"])
-					row.AddCell().SetValue(v["subtype"])
-					row.AddCell().SetValue(v["detail"])
-					if v["publishtime"] != nil {
-						row.AddCell().SetValue(time.Unix(qu.Int64All(v["publishtime"]), 0).Format("2006-01-02"))
-					} else {
-						row.AddCell()
-					}
-					row.AddCell().SetValue(v["href"])
-					row.AddCell().SetValue(v["jybxhref"])
-					row.AddCell().SetValue(v["projectname"])
-					row.AddCell().SetValue(v["projectcode"])
-					row.AddCell().SetValue(v["projectscope"])
-					if v["budget"] != nil {
-						row.AddCell().SetFloat(qu.Float64All(v["budget"]))
-					} else {
-						row.AddCell()
-					}
-					if v["bidamount"] != nil {
-						row.AddCell().SetFloat(qu.Float64All(v["bidamount"]))
-					} else {
-						row.AddCell()
-					}
-					if v["bidopentime"] != nil {
-						row.AddCell().SetValue(time.Unix(qu.Int64All(v["bidopentime"]), 0).Format("2006-01-02"))
-					} else {
-						row.AddCell()
+					items := strings.Split(v["item"].(string), ",")
+					for _, i := range items {
+						if len(items) > 1 {
+							v["matchkey"] = v["itemdist"].(map[string]interface{})[i]
+							v["item"] = i
+						}
+						var sheet *xlsx.Sheet
+						if _, ok := newFile.Sheet[v["item"].(string)]; ok {
+							sheet = newFile.Sheet[v["item"].(string)]
+						} else {
+							sheet, err = newFile.AppendSheet(*sh, v["item"].(string))
+						}
+						row := sheet.AddRow()
+						// row.AddCell().SetInt(i + 1)
+						row.AddCell().SetValue(v["matchkey"])
+						row.AddCell().SetValue(v["area"])
+						row.AddCell().SetValue(v["city"])
+						row.AddCell().SetValue(v["title"])
+						row.AddCell().SetValue(v["subtype"])
+						row.AddCell().SetValue(v["detail"])
+						if v["publishtime"] != nil {
+							row.AddCell().SetValue(time.Unix(qu.Int64All(v["publishtime"]), 0).Format("2006-01-02"))
+						} else {
+							row.AddCell()
+						}
+						row.AddCell().SetValue(v["href"])
+						row.AddCell().SetValue(v["jybxhref"])
+						row.AddCell().SetValue(v["projectname"])
+						row.AddCell().SetValue(v["projectcode"])
+						row.AddCell().SetValue(v["projectscope"])
+						if v["budget"] != nil {
+							row.AddCell().SetFloat(qu.Float64All(v["budget"]))
+						} else {
+							row.AddCell()
+						}
+						if v["bidamount"] != nil {
+							row.AddCell().SetFloat(qu.Float64All(v["bidamount"]))
+						} 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["buyer"])
+						row.AddCell().SetValue(v["buyerperson"])
+						row.AddCell().SetValue(v["buyertel"])
+						row.AddCell().SetValue(v["agency"])
+						row.AddCell().SetValue(v["s_winner"])
+						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["buyer"])
-					row.AddCell().SetValue(v["buyerperson"])
-					row.AddCell().SetValue(v["buyertel"])
-					row.AddCell().SetValue(v["agency"])
-					row.AddCell().SetValue(v["s_winner"])
-					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)
-
 				}
 				//xf.Sheets = xf.Sheets[1:2]
 			} else if dataType == 3 {
 				sh := xf.Sheets[2]
 				for _, v := range mMap {
-					if v["item"].(string)==""{
+					if v["item"].(string) == "" {
 						v["item"] = "其他方式"
 					}
-					var sheet *xlsx.Sheet
-					if _,ok :=newFile.Sheet[v["item"].(string)];ok{
-						sheet = newFile.Sheet[v["item"].(string)]
-					}else {
-						sheet ,err =newFile.AppendSheet(*sh,v["item"].(string))
-					}
-					row := sheet.AddRow()
-					// row.AddCell().SetInt(i + 1)
-					row.AddCell().SetValue(v["departname"])
-					row.AddCell().SetValue(v["rulename"])
-					row.AddCell().SetValue(v["matchkey"])
-					row.AddCell().SetValue(v["toptype"])
-					row.AddCell().SetValue(v["area"])
-					row.AddCell().SetValue(v["city"])
-					row.AddCell().SetValue(v["district"])
-					row.AddCell().SetValue(v["title"])
-					row.AddCell().SetValue(v["detail"])
-					if v["publishtime"] != nil {
-						row.AddCell().SetValue(time.Unix(qu.Int64All(v["publishtime"]), 0).Format("2006-01-02"))
-					} else {
-						row.AddCell()
-					}
-					row.AddCell().SetValue(v["href"])
-					if v["bidamount"] != nil {
-						row.AddCell().SetFloat(qu.Float64All(v["bidamount"]))
-					} else {
-						row.AddCell()
+					items := strings.Split(v["item"].(string), ",")
+					for _, i := range items {
+						if len(items) > 1 {
+							v["matchkey"] = v["itemdist"].(map[string]interface{})[i]
+							v["item"] = i
+						}
+						var sheet *xlsx.Sheet
+						if _, ok := newFile.Sheet[v["item"].(string)]; ok {
+							sheet = newFile.Sheet[v["item"].(string)]
+						} else {
+							sheet, err = newFile.AppendSheet(*sh, v["item"].(string))
+						}
+						row := sheet.AddRow()
+						// row.AddCell().SetInt(i + 1)
+						row.AddCell().SetValue(v["departname"])
+						row.AddCell().SetValue(v["rulename"])
+						row.AddCell().SetValue(v["matchkey"])
+						row.AddCell().SetValue(v["toptype"])
+						row.AddCell().SetValue(v["area"])
+						row.AddCell().SetValue(v["city"])
+						row.AddCell().SetValue(v["district"])
+						row.AddCell().SetValue(v["title"])
+						row.AddCell().SetValue(v["detail"])
+						if v["publishtime"] != nil {
+							row.AddCell().SetValue(time.Unix(qu.Int64All(v["publishtime"]), 0).Format("2006-01-02"))
+						} else {
+							row.AddCell()
+						}
+						row.AddCell().SetValue(v["href"])
+						if v["bidamount"] != nil {
+							row.AddCell().SetFloat(qu.Float64All(v["bidamount"]))
+						} else {
+							row.AddCell()
+						}
+						row.AddCell().SetValue(v["buyer"])
+						row.AddCell().SetValue(v["buyerclass"])
+						row.AddCell().SetValue(v["buyerperson"])
+						row.AddCell().SetValue(v["buyertel"])
+						row.AddCell().SetValue(v["s_winner"])
+						row.AddCell().SetValue(v["legal_person"])
+						row.AddCell().SetValue(v["company_phone"])
+						row.AddCell().SetValue(v["company_address"])
+						row.AddCell().SetValue(v["rank"])
+						row.AddCell().SetValue(v["purchasing"])
+						row.AddCell().SetValue(v["capital"])
+						row.AddCell().SetValue(v["establish_date"])
+						row.AddCell().SetValue(v["business_scope"])
+						row.AddCell().SetValue(v["stock_name"])
+						row.AddCell().SetValue(v["buyer_credit_no"])
+						row.AddCell().SetValue(v["winner_credit_no"])
+						ids := SE.EncodeString(qu.ObjToString(v["id"]))
+						row.AddCell().SetValue(ids)
 					}
-					row.AddCell().SetValue(v["buyer"])
-					row.AddCell().SetValue(v["buyerclass"])
-					row.AddCell().SetValue(v["buyerperson"])
-					row.AddCell().SetValue(v["buyertel"])
-					row.AddCell().SetValue(v["s_winner"])
-					row.AddCell().SetValue(v["legal_person"])
-					row.AddCell().SetValue(v["company_phone"])
-					row.AddCell().SetValue(v["company_address"])
-					row.AddCell().SetValue(v["rank"])
-					row.AddCell().SetValue(v["purchasing"])
-					row.AddCell().SetValue(v["capital"])
-					row.AddCell().SetValue(v["establish_date"])
-					row.AddCell().SetValue(v["business_scope"])
-					row.AddCell().SetValue(v["stock_name"])
-					row.AddCell().SetValue(v["buyer_credit_no"])
-					row.AddCell().SetValue(v["winner_credit_no"])
-					ids := SE.EncodeString(qu.ObjToString(v["id"]))
-					row.AddCell().SetValue(ids)
 				}
 				//xf.Sheets = xf.Sheets[2:3]
 			} else if dataType == 4 {
 				sh := xf.Sheets[3]
 				for _, v := range mMap {
-					if v["item"].(string)==""{
+					if v["item"].(string) == "" {
 						v["item"] = "其他方式"
 					}
-					var sheet *xlsx.Sheet
-					if _,ok :=newFile.Sheet[v["item"].(string)];ok{
-						sheet = newFile.Sheet[v["item"].(string)]
-					}else {
-						sheet ,err =newFile.AppendSheet(*sh,v["item"].(string))
-					}
-					row := sheet.AddRow()
-					// row.AddCell().SetInt(i + 1)
-					row.AddCell().SetValue(v["departname"])
-					row.AddCell().SetValue(v["rulename"])
-					row.AddCell().SetValue(v["matchkey"])
-					row.AddCell().SetValue(v["area"])
-					row.AddCell().SetValue(v["city"])
-					row.AddCell().SetValue(v["title"])
-					row.AddCell().SetValue(v["subtype"])
-					row.AddCell().SetValue(v["detail"])
-					if v["publishtime"] != nil {
-						row.AddCell().SetValue(time.Unix(qu.Int64All(v["publishtime"]), 0).Format("2006-01-02"))
-					} else {
-						row.AddCell()
-					}
-					row.AddCell().SetValue(v["href"])
-					row.AddCell().SetValue(v["jybxhref"])
-					row.AddCell().SetValue(v["projectname"])
-					row.AddCell().SetValue(v["projectcode"])
-					row.AddCell().SetValue(v["projectscope"])
-					if v["budget"] != nil {
-						row.AddCell().SetFloat(qu.Float64All(v["budget"]))
-					} else {
-						row.AddCell()
-					}
-					if v["bidamount"] != nil {
-						row.AddCell().SetFloat(qu.Float64All(v["bidamount"]))
-					} else {
-						row.AddCell()
-					}
-					if v["bidopentime"] != nil {
-						row.AddCell().SetValue(time.Unix(qu.Int64All(v["bidopentime"]), 0).Format("2006-01-02"))
-					} else {
-						row.AddCell()
+					items := strings.Split(v["item"].(string), ",")
+					for _, i := range items {
+						if len(items) > 1 {
+							v["matchkey"] = v["itemdist"].(map[string]interface{})[i]
+							v["item"] = i
+						}
+						var sheet *xlsx.Sheet
+						if _, ok := newFile.Sheet[v["item"].(string)]; ok {
+							sheet = newFile.Sheet[v["item"].(string)]
+						} else {
+							sheet, err = newFile.AppendSheet(*sh, v["item"].(string))
+						}
+						row := sheet.AddRow()
+						// row.AddCell().SetInt(i + 1)
+						row.AddCell().SetValue(v["departname"])
+						row.AddCell().SetValue(v["rulename"])
+						row.AddCell().SetValue(v["matchkey"])
+						row.AddCell().SetValue(v["area"])
+						row.AddCell().SetValue(v["city"])
+						row.AddCell().SetValue(v["title"])
+						row.AddCell().SetValue(v["subtype"])
+						row.AddCell().SetValue(v["detail"])
+						if v["publishtime"] != nil {
+							row.AddCell().SetValue(time.Unix(qu.Int64All(v["publishtime"]), 0).Format("2006-01-02"))
+						} else {
+							row.AddCell()
+						}
+						row.AddCell().SetValue(v["href"])
+						row.AddCell().SetValue(v["jybxhref"])
+						row.AddCell().SetValue(v["projectname"])
+						row.AddCell().SetValue(v["projectcode"])
+						row.AddCell().SetValue(v["projectscope"])
+						if v["budget"] != nil {
+							row.AddCell().SetFloat(qu.Float64All(v["budget"]))
+						} else {
+							row.AddCell()
+						}
+						if v["bidamount"] != nil {
+							row.AddCell().SetFloat(qu.Float64All(v["bidamount"]))
+						} 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["buyer"])
+						row.AddCell().SetValue(v["buyerperson"])
+						row.AddCell().SetValue(v["buyertel"])
+						row.AddCell().SetValue(v["agency"])
+						row.AddCell().SetValue(v["s_winner"])
+						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["buyer"])
-					row.AddCell().SetValue(v["buyerperson"])
-					row.AddCell().SetValue(v["buyertel"])
-					row.AddCell().SetValue(v["agency"])
-					row.AddCell().SetValue(v["s_winner"])
-					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)
 				}
 				//xf.Sheets = xf.Sheets[3:4]
 			} else if dataType == 5 {
 				sh := xf.Sheets[4]
 				for _, v := range mMap {
-					if v["item"].(string)==""{
+					if v["item"].(string) == "" {
 						v["item"] = "其他方式"
 					}
-					var sheet *xlsx.Sheet
-					if _,ok :=newFile.Sheet[v["item"].(string)];ok{
-						sheet = newFile.Sheet[v["item"].(string)]
-					}else {
-						sheet ,err =newFile.AppendSheet(*sh,v["item"].(string))
-					}
-					row := sheet.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["buyer_type"])  //采购单位类别---私有标签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()
+					items := strings.Split(v["item"].(string), ",")
+					for _, i := range items {
+						if len(items) > 1 {
+							v["matchkey"] = v["itemdist"].(map[string]interface{})[i]
+							v["item"] = i
+						}
+						var sheet *xlsx.Sheet
+						if _, ok := newFile.Sheet[v["item"].(string)]; ok {
+							sheet = newFile.Sheet[v["item"].(string)]
+						} else {
+							sheet, err = newFile.AppendSheet(*sh, v["item"].(string))
+						}
+						row := sheet.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["buyer_type"])  //采购单位类别---私有标签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["winner_type"])        //中标模式--移动、电信、联通
+						row.AddCell().SetValue(v["title"])              //公告标题
+						row.AddCell().SetValue(v["subtype"])            //公告类别
+						row.AddCell().SetValue(v["area"])               //省份
+						row.AddCell().SetValue(v["projectcode"])        //项目编号
+						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"])
 					}
-					row.AddCell().SetValue(v["s_winner"])           //中标单位
-					row.AddCell().SetValue(v["winner_type"])        //中标模式--移动、电信、联通
-					row.AddCell().SetValue(v["title"])              //公告标题
-					row.AddCell().SetValue(v["subtype"])            //公告类别
-					row.AddCell().SetValue(v["area"])               //省份
-					row.AddCell().SetValue(v["projectcode"])        //项目编号
-					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]
 			}

+ 5 - 4
src/util/parsxlsx.go

@@ -234,7 +234,7 @@ func writeMap1(tmp map[string]string, i int, v string) {
 	}
 }
 
-var bzpath, gjpath, rpath string = "web/res/标准字段包%d.xlsx", "web/res/高级字段包%d.xlsx", "web/res/%s_%d.xlsx"
+var bzpath, gjpath, rpath string = "web/res/%s_数据_%d.xlsx", "web/res/%s_数据_%d.xlsx", "web/res/%s_规则_%d.xlsx"
 
 func ResponseXlsx_Data(id string) string {
 	if id != "" {
@@ -242,6 +242,7 @@ func ResponseXlsx_Data(id string) string {
 			"_id": bson.ObjectIdHex(id),
 		}
 		data, _ := Mgo.FindOne("cuserdepartrule", query)
+		ruleName := (*data)["s_name"]
 		if (*data) != nil && len(*data) > 0 {
 			isStandard := true
 			if util.Int64All((*data)["i_extfieldstype"]) == Advanced {
@@ -285,7 +286,7 @@ func ResponseXlsx_Data(id string) string {
 				}
 				xf.Sheets = xf.Sheets[:1]
 				xf.Sheets[0].Name = "详细数据"
-				fname := fmt.Sprintf(bzpath, time.Now().Unix())
+				fname := fmt.Sprintf(bzpath, ruleName, time.Now().Unix())
 				err := xf.Save(fname)
 				if err != nil {
 					log.Println(err)
@@ -343,7 +344,7 @@ func ResponseXlsx_Data(id string) string {
 				}
 				xf.Sheets = xf.Sheets[1:2]
 				xf.Sheets[0].Name = "详细数据"
-				fname := fmt.Sprintf(gjpath, time.Now().Unix())
+				fname := fmt.Sprintf(gjpath, ruleName, time.Now().Unix())
 				err := xf.Save(fname)
 				if err != nil {
 					log.Println(err)
@@ -419,7 +420,7 @@ func ResponseXlsx_Rule(id string) string {
 		}
 	}
 	ruleName := (*data)["s_name"]
-	fname := fmt.Sprintf(rpath, ruleName,time.Now().Unix())
+	fname := fmt.Sprintf(rpath, ruleName, time.Now().Unix())
 	xf.Save(fname)
 	return fname
 }