Browse Source

feat:生 xlsx 判空

xuzhiheng 3 years ago
parent
commit
75df3d91b6
3 changed files with 37 additions and 15 deletions
  1. 3 2
      src/history/util_history.go
  2. 31 10
      src/service/private_service.go
  3. 3 3
      src/service/second_push.go

+ 3 - 2
src/history/util_history.go

@@ -10,6 +10,7 @@ import (
 	"regexp"
 	"regexp"
 	"strings"
 	"strings"
 	"time"
 	"time"
+
 	. "util"
 	. "util"
 	"util/mgodb"
 	"util/mgodb"
 
 
@@ -559,7 +560,7 @@ func AssembelSave(tmp map[string]interface{}, IsSearchHosp, IsSearchEnps bool, h
 	//if ProjectAppidMap[appid] {
 	//if ProjectAppidMap[appid] {
 	//log.Println("补充信息中根据项目id去重。。。。")
 	//log.Println("补充信息中根据项目id去重。。。。")
 	//所有的数据都匹配项目id,是否去重根据isFilter
 	//所有的数据都匹配项目id,是否去重根据isFilter
-	projectId := GetProjectId(id)
+	projectId := getProjectId(id)
 	if projectId != "" {
 	if projectId != "" {
 		projectIds := strings.Split(projectId, ",")
 		projectIds := strings.Split(projectId, ",")
 		tmp["projectId"] = projectId
 		tmp["projectId"] = projectId
@@ -1510,7 +1511,7 @@ func PathExists(path string) (bool, error) {
 	return false, err
 	return false, err
 }
 }
 
 
-func GetProjectId(id string) string {
+func getProjectId(id string) string {
 	query := `{"query": {"bool": {"must": [{"term": {"projectset.ids": "%s"}}],"must_not": [],"should": []}}}`
 	query := `{"query": {"bool": {"must": [{"term": {"projectset.ids": "%s"}}],"must_not": [],"should": []}}}`
 	querys := fmt.Sprintf(query, id)
 	querys := fmt.Sprintf(query, id)
 	projectId := ""
 	projectId := ""

+ 31 - 10
src/service/private_service.go

@@ -303,7 +303,24 @@ func GetXlsxfile(mMap []map[string]interface{}, dataType int, fn string, fields
 			if len(fields) > 0 {
 			if len(fields) > 0 {
 				for _, vv := range fields {
 				for _, vv := range fields {
 					for kk, _ := range vv {
 					for kk, _ := range vv {
-						row.AddCell().SetValue(v[kk])
+						if v[kk] != nil {
+							if kk == "filehref" {
+								if filehrefs, ok := v["filehref"].([]interface{}); ok {
+									urlArr := ""
+									for _, href := range filehrefs {
+										if hrefs, oks := href.(map[string]interface{}); oks {
+											url := qu.ObjToString(hrefs["url"]) + "\n"
+											urlArr += url
+										}
+									}
+									row.AddCell().SetValue(urlArr)
+								}
+							} else {
+								row.AddCell().SetValue(v[kk])
+							}
+						} else {
+							row.AddCell()
+						}
 					}
 					}
 				}
 				}
 			}
 			}
@@ -368,19 +385,23 @@ func GetXlsxfile(mMap []map[string]interface{}, dataType int, fn string, fields
 			if len(fields) > 0 {
 			if len(fields) > 0 {
 				for _, vv := range fields {
 				for _, vv := range fields {
 					for kk, _ := range vv {
 					for kk, _ := range vv {
-						if kk == "filehref" {
-							if filehrefs, ok := v["filehref"].([]interface{}); ok {
-								urlArr := ""
-								for _, href := range filehrefs {
-									if hrefs, oks := href.(map[string]interface{}); oks {
-										url := qu.ObjToString(hrefs["url"]) + "\n"
-										urlArr += url
+						if v[kk] != nil {
+							if kk == "filehref" {
+								if filehrefs, ok := v["filehref"].([]interface{}); ok {
+									urlArr := ""
+									for _, href := range filehrefs {
+										if hrefs, oks := href.(map[string]interface{}); oks {
+											url := qu.ObjToString(hrefs["url"]) + "\n"
+											urlArr += url
+										}
 									}
 									}
+									row.AddCell().SetValue(urlArr)
 								}
 								}
-								row.AddCell().SetValue(urlArr)
+							} else {
+								row.AddCell().SetValue(v[kk])
 							}
 							}
 						} else {
 						} else {
-							row.AddCell().SetValue(v[kk])
+							row.AddCell()
 						}
 						}
 					}
 					}
 				}
 				}

+ 3 - 3
src/service/second_push.go

@@ -304,7 +304,7 @@ func (s *SecondPush) SecondPushTask() {
 }
 }
 func searchProjectId(l map[string]interface{}, updateMap [][]map[string]interface{}) [][]map[string]interface{} {
 func searchProjectId(l map[string]interface{}, updateMap [][]map[string]interface{}) [][]map[string]interface{} {
 	_projectid := ""
 	_projectid := ""
-	projectId := GetProjectId(qu.ObjToString(l["id"]))
+	projectId := getProjectId(qu.ObjToString(l["id"]))
 	if projectId != "" {
 	if projectId != "" {
 		l["projectId"] = projectId
 		l["projectId"] = projectId
 		_projectid = projectId
 		_projectid = projectId
@@ -328,7 +328,7 @@ func searchProjectId(l map[string]interface{}, updateMap [][]map[string]interfac
 	}
 	}
 	return updateMap
 	return updateMap
 }
 }
-func GetProjectId(id string) string {
+func getProjectId(id string) string {
 	query := `{"query": {"bool": {"must": [{"term": {"projectset.ids": "%s"}}],"must_not": [],"should": []}}}`
 	query := `{"query": {"bool": {"must": [{"term": {"projectset.ids": "%s"}}],"must_not": [],"should": []}}}`
 	querys := fmt.Sprintf(query, id)
 	querys := fmt.Sprintf(query, id)
 	projectId := ""
 	projectId := ""
@@ -784,7 +784,7 @@ func GetXlsxs(mMap []map[string]interface{}, fn, email, id, appid string) {
 						row.AddCell().SetValue(v["projectname"]) //项目名称
 						row.AddCell().SetValue(v["projectname"]) //项目名称
 						row.AddCell().SetValue(v["buyer"])       //采购单位
 						row.AddCell().SetValue(v["buyer"])       //采购单位
 						row.AddCell().SetValue(v["buyer_type"])  //采购单位类别---私有标签tagname
 						row.AddCell().SetValue(v["buyer_type"])  //采购单位类别---私有标签tagname
-						if v["bidamount"] != nil { //中标金额
+						if v["bidamount"] != nil {               //中标金额
 							row.AddCell().SetFloat(qu.Float64All(v["bidamount"]))
 							row.AddCell().SetFloat(qu.Float64All(v["bidamount"]))
 						} else {
 						} else {
 							row.AddCell()
 							row.AddCell()