|
@@ -484,6 +484,7 @@ func AssembelSave(tmp map[string]interface{}, IsSearchHosp, IsSearchEnps bool, h
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ xlsxArr = append(xlsxArr, tmp)
|
|
|
MgoSaveCache <- tmp
|
|
|
return true
|
|
|
}
|
|
@@ -586,7 +587,6 @@ func SaveMgo() {
|
|
|
select {
|
|
|
case v := <-MgoSaveCache:
|
|
|
arru[indexu] = v
|
|
|
- xlsxArr = append(xlsxArr, v)
|
|
|
indexu++
|
|
|
if indexu == 500 {
|
|
|
SP <- true
|
|
@@ -793,73 +793,190 @@ func SkipData(tmp map[string]interface{}) bool {
|
|
|
}
|
|
|
|
|
|
//生成xlsx
|
|
|
-func GetXlsx(mMap []map[string]interface{}, fn, email string) {
|
|
|
- //信息
|
|
|
- var err error
|
|
|
- //样式
|
|
|
- fx := xlsx.NewFile()
|
|
|
- style := xlsx.NewStyle()
|
|
|
- border := *xlsx.NewBorder("thin", "thin", "thin", "thin")
|
|
|
- style.Border = border
|
|
|
- style.Font.Size = 14
|
|
|
- style.Alignment.Vertical = "center"
|
|
|
- style.ApplyBorder = true
|
|
|
- //
|
|
|
- styleHead := xlsx.NewStyle()
|
|
|
- styleHead.Font.Bold = true
|
|
|
- styleHead.Font.Size = 18
|
|
|
- styleHead.Border = border
|
|
|
- styleHead.ApplyBorder = true
|
|
|
-
|
|
|
- sheet1, err := fx.AddSheet("Sheet")
|
|
|
- if err != nil {
|
|
|
- log.Println("Err", err.Error())
|
|
|
- }
|
|
|
- head := sheet1.AddRow()
|
|
|
- fields := []string{}
|
|
|
- for r, _ := range FielsArr {
|
|
|
- fields = append(fields, r)
|
|
|
- }
|
|
|
+// func GetXlsxs(mMap []map[string]interface{}, fn, email string) {
|
|
|
+// //信息
|
|
|
+// var err error
|
|
|
+// //样式
|
|
|
+// fx := xlsx.NewFile()
|
|
|
+// style := xlsx.NewStyle()
|
|
|
+// border := *xlsx.NewBorder("thin", "thin", "thin", "thin")
|
|
|
+// style.Border = border
|
|
|
+// style.Font.Size = 14
|
|
|
+// style.Alignment.Vertical = "center"
|
|
|
+// style.ApplyBorder = true
|
|
|
+// //
|
|
|
+// styleHead := xlsx.NewStyle()
|
|
|
+// styleHead.Font.Bold = true
|
|
|
+// styleHead.Font.Size = 18
|
|
|
+// styleHead.Border = border
|
|
|
+// styleHead.ApplyBorder = true
|
|
|
|
|
|
- for _, t := range fields {
|
|
|
- if FielsArr[t] != nil {
|
|
|
- cell := head.AddCell()
|
|
|
- cell.SetValue(FielsArr[t])
|
|
|
- cell.SetStyle(styleHead)
|
|
|
- }
|
|
|
- }
|
|
|
+// sheet1, err := fx.AddSheet("Sheet")
|
|
|
+// if err != nil {
|
|
|
+// log.Println("Err", err.Error())
|
|
|
+// }
|
|
|
+// head := sheet1.AddRow()
|
|
|
+// fields := []string{"title", "href", "detail", "publishtime", "matchkey", "area", "city", "district", "buyer", "buyerperson", "buyertel", "s_winner", "legal_person", "company_phone", "bidamount", "rank", "purchasing", "company_address", "capital", "establish_date", "business_scope", "stock_name", "buyer_credit_no", "winner_credit_no", "id"}
|
|
|
+// // for r, _ := range FielsArr {
|
|
|
+// // fields = append(fields, r)
|
|
|
+// // }
|
|
|
|
|
|
- for _, v := range mMap {
|
|
|
- row := sheet1.AddRow()
|
|
|
- for _, t := range fields {
|
|
|
- cell := row.AddCell()
|
|
|
- cell.SetStyle(style)
|
|
|
- if v[t] != nil {
|
|
|
- cell.SetValue(v[t])
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+// for _, t := range fields {
|
|
|
+// if FielsArr[t] != nil {
|
|
|
+// cell := head.AddCell()
|
|
|
+// cell.SetValue(FielsArr[t])
|
|
|
+// cell.SetStyle(styleHead)
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+// for _, v := range mMap {
|
|
|
+// row := sheet1.AddRow()
|
|
|
+// for _, t := range fields {
|
|
|
+// cell := row.AddCell()
|
|
|
+// cell.SetStyle(style)
|
|
|
+// if v[t] != nil {
|
|
|
+// cell.SetValue(v[t])
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
- //生文件
|
|
|
- t := strconv.FormatInt(time.Now().Unix(), 10)
|
|
|
- dir := "./web/res/xlsx/" + t + "/"
|
|
|
- if b, _ := PathExists(dir); !b {
|
|
|
- err1 := os.MkdirAll(dir, os.ModePerm)
|
|
|
- if err1 != nil {
|
|
|
- log.Println("mkdir err", dir)
|
|
|
+// //生文件
|
|
|
+// t := strconv.FormatInt(time.Now().Unix(), 10)
|
|
|
+// dir := "./web/res/xlsx/" + t + "/"
|
|
|
+// if b, _ := PathExists(dir); !b {
|
|
|
+// err1 := os.MkdirAll(dir, os.ModePerm)
|
|
|
+// if err1 != nil {
|
|
|
+// log.Println("mkdir err", dir)
|
|
|
+// }
|
|
|
+// }
|
|
|
+// fname := t + ".xlsx"
|
|
|
+// err = fx.Save(dir + fname)
|
|
|
+// if err != nil {
|
|
|
+// log.Println("xls error", fname)
|
|
|
+// } else {
|
|
|
+// for i := 0; i < len(Gmails); i++ {
|
|
|
+// gmail := Gmails[i]
|
|
|
+// status := mail.GSendMail_q("剑鱼标讯", email, "", "", fn, "", dir+fname, fname, gmail)
|
|
|
+// if status {
|
|
|
+// log.Println("send mail success", fname, email)
|
|
|
+// break
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+func GetXlsxs(mMap []map[string]interface{}, fn, email, id string) {
|
|
|
+ if id != "" {
|
|
|
+ query := bson.M{
|
|
|
+ "_id": bson.ObjectIdHex(id),
|
|
|
}
|
|
|
- }
|
|
|
- fname := t + ".xlsx"
|
|
|
- err = fx.Save(dir + fname)
|
|
|
- if err != nil {
|
|
|
- log.Println("xls error", fname)
|
|
|
- } else {
|
|
|
- for i := 0; i < len(Gmails); i++ {
|
|
|
- gmail := Gmails[i]
|
|
|
- status := mail.GSendMail_q("剑鱼标讯", email, "", "", fn, "", dir+fname, fname, gmail)
|
|
|
- if status {
|
|
|
- log.Println("send mail success", fname, email)
|
|
|
- break
|
|
|
+ data, ok := Mgo.FindOne("historylog", query)
|
|
|
+ if ok && (*data) != nil && len(*data) > 0 {
|
|
|
+ dataType := qu.IntAll((*data)["i_extfieldstype"])
|
|
|
+ xf, err := xlsx.OpenFile("web/res/fields.xlsx")
|
|
|
+ if err != nil {
|
|
|
+ log.Println("fields file not foud", err.Error())
|
|
|
+ }
|
|
|
+ if dataType == 1 {
|
|
|
+ sh := xf.Sheets[0]
|
|
|
+ for i, v := range mMap {
|
|
|
+ row := sh.AddRow()
|
|
|
+ row.AddCell().SetInt(i + 1)
|
|
|
+ row.AddCell().SetValue(v["s_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["winner"])
|
|
|
+ if v["bidamount"] != nil {
|
|
|
+ row.AddCell().SetFloat(qu.Float64All(v["bidamount"]) / 10000)
|
|
|
+ } else {
|
|
|
+ row.AddCell()
|
|
|
+ }
|
|
|
+ row.AddCell().SetValue(v["projectname"])
|
|
|
+ row.AddCell().SetValue(v["detail"])
|
|
|
+ row.AddCell().SetValue(v["s_jyhref"])
|
|
|
+ }
|
|
|
+ xf.Sheets = xf.Sheets[:1]
|
|
|
+ } else if dataType == 2 {
|
|
|
+ sh := xf.Sheets[1]
|
|
|
+ for i, v := range mMap {
|
|
|
+ row := sh.AddRow()
|
|
|
+ row.AddCell().SetInt(i + 1)
|
|
|
+ row.AddCell().SetValue(v["s_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["s_jyhref"])
|
|
|
+ row.AddCell().SetValue(v["projectcode"])
|
|
|
+ row.AddCell().SetValue(v["projectname"])
|
|
|
+ row.AddCell().SetValue(v["projectscope"])
|
|
|
+ if v["budget"] != nil {
|
|
|
+ row.AddCell().SetFloat(qu.Float64All(v["budget"]) / 10000)
|
|
|
+ } else {
|
|
|
+ row.AddCell()
|
|
|
+ }
|
|
|
+ if v["bidamount"] != nil {
|
|
|
+ row.AddCell().SetFloat(qu.Float64All(v["bidamount"]) / 10000)
|
|
|
+ } 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["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"])
|
|
|
+ }
|
|
|
+ xf.Sheets = xf.Sheets[1:]
|
|
|
+ } else {
|
|
|
+
|
|
|
+ }
|
|
|
+ //生文件
|
|
|
+ t := strconv.FormatInt(time.Now().Unix(), 10)
|
|
|
+ dir := "./web/res/xlsx/" + t + "/"
|
|
|
+ if b, _ := PathExists(dir); !b {
|
|
|
+ err1 := os.MkdirAll(dir, os.ModePerm)
|
|
|
+ if err1 != nil {
|
|
|
+ log.Println("mkdir err", dir)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fname := t + ".xlsx"
|
|
|
+ err = xf.Save(dir + fname)
|
|
|
+ if err != nil {
|
|
|
+ log.Println("xls error", fname)
|
|
|
+ } else {
|
|
|
+ for i := 0; i < len(Gmails); i++ {
|
|
|
+ gmail := Gmails[i]
|
|
|
+ status := mail.GSendMail_q("剑鱼标讯", email, "", "", fn, "", dir+fname, fname, gmail)
|
|
|
+ if status {
|
|
|
+ log.Println("send mail success", fname, email)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|