فهرست منبع

excel附件链接

jiaojiao7 4 سال پیش
والد
کامیت
88a80361bd
7فایلهای تغییر یافته به همراه106 افزوده شده و 23 حذف شده
  1. 8 2
      src/config.json
  2. 18 16
      src/history/datamodel.go
  3. 1 1
      src/history/historytask.go
  4. 36 1
      src/history/util_history.go
  5. 6 0
      src/main.go
  6. 37 3
      src/service/second_push.go
  7. BIN
      src/web/res/fields.xlsx

+ 8 - 2
src/config.json

@@ -36,7 +36,7 @@
 		"hospcoll": "buyer_rank",
 		"buyerentcoll": "buyer_ent"
 	},
-	"enterprise": { 
+	"enterprise": {
 		"addr": "192.168.3.207:27092",
 		"size": 15,
 		"db": "zyx",
@@ -146,5 +146,11 @@
 		"db": "qfw_data",
 		"size": 15
 	},
-	"file_downloadurl": "http://jy-datafile.oss-cn-beijing.aliyuncs.com/"
+	"file_downloadurl": "http://jy-datafile.oss-cn-beijing.aliyuncs.com/",
+	"filter_filehref_appid": [
+		"jyFzZXQQIECAZYQERAPD93"
+	],
+	"need_filehref_appid":[
+      "jyFzZXQQIECAZYQERAPD93"
+    ]
 }

+ 18 - 16
src/history/datamodel.go

@@ -69,19 +69,21 @@ import (
 // 	"tagname":          "标签名称",
 // }
 var (
-	MgoSaveCache          = make(chan map[string]interface{}, 1000)
-	MgoSaveUsermailCache  = make(chan map[string]interface{}, 1000)
-	xlsxArr               = []map[string]interface{}{}
-	SP                    = make(chan bool, 5)
-	xlsxCount             = 0
-	SE                    = util.SimpleEncrypt{Key: "topJYBX2019"}
-	ProjectAppidMap       = map[string]bool{}
-	projectIdMap          = sync.Map{}
-	FileTextAppidMap      = map[string]bool{}
-	CheckBidOpenAppidMap  = map[string]bool{}
-	CheckBidHrefRuleIdMap = map[string]bool{}
-	DisPackageAppidMap    = map[string]bool{}
-	NeedProjectidAppidMap = map[string]bool{}
+	MgoSaveCache           = make(chan map[string]interface{}, 1000)
+	MgoSaveUsermailCache   = make(chan map[string]interface{}, 1000)
+	xlsxArr                = []map[string]interface{}{}
+	SP                     = make(chan bool, 5)
+	xlsxCount              = 0
+	SE                     = util.SimpleEncrypt{Key: "topJYBX2019"}
+	ProjectAppidMap        = map[string]bool{}
+	projectIdMap           = sync.Map{}
+	FileTextAppidMap       = map[string]bool{}
+	CheckBidOpenAppidMap   = map[string]bool{}
+	CheckBidHrefRuleIdMap  = map[string]bool{}
+	DisPackageAppidMap     = map[string]bool{}
+	NeedProjectidAppidMap  = map[string]bool{}
+	FilterFilehrefAppidMap = map[string]bool{}
+	NeedFilehrefAppidMap      = map[string]bool{}
 )
 
 //客户模型
@@ -96,7 +98,7 @@ type Customer struct {
 	IsSearchEnps bool                              //是否查询第三方企业信息
 	TagRules     []*TagRule                        //打标签规则集合
 	SaveDataMap  map[string]map[string]interface{} //最终入库数据(全局模式)
-	SaveDataArr  []map[string]interface{} //最终入库数据(规则模式)
+	SaveDataArr  []map[string]interface{}          //最终入库数据(规则模式)
 	IdRange      bson.M                            //由当前时间生成是id查询区间
 }
 
@@ -107,8 +109,8 @@ type Department struct {
 	CustomerID     string                              //所属客户id
 	Rules          []*SearchRule                       //客户的多个规则
 	DepartmentData map[string][]map[string]interface{} //部门所有数据 key:ruleid value:[{k:dataid v:data},{k:dataid v:data}]
-	DataLock       *sync.Mutex                         //数据锁
-	SaveDataMap    map[string]map[string]interface{}   //最终入库数据(部门内部去重)
+	DataLock    *sync.Mutex                            //数据锁
+	SaveDataMap map[string]map[string]interface{}      //最终入库数据(部门内部去重)
 }
 
 //查询规则模型

+ 1 - 1
src/history/historytask.go

@@ -135,7 +135,7 @@ func (this *HistoryData) HistoryTask(history_id string) {
 				if len(xlsxArr) != xlsxCount {
 					log.Println("excel数据量错误")
 				}
-				GetXlsxs(xlsxArr, customer_name, email, history_id, isfile, isHenanMobile)
+				GetXlsxs(xlsxArr, customer_name, email, history_id, isfile, isHenanMobile, appId)
 				go UpdateHistoryState(2, history_id, xlsxCount)
 				xlsxArr = []map[string]interface{}{}
 				xlsxCount = 0

+ 36 - 1
src/history/util_history.go

@@ -1142,7 +1142,7 @@ func SkipData(tmp map[string]interface{}) bool {
 	return false
 }
 
-func GetXlsxs(mMap []map[string]interface{}, fn, email, id string, isfile, isHenanMobile bool) {
+func GetXlsxs(mMap []map[string]interface{}, fn, email, id string, isfile, isHenanMobile bool, appid string) {
 	if id != "" {
 		query := bson.M{
 			"_id": bson.ObjectIdHex(id),
@@ -1197,6 +1197,7 @@ func GetXlsxs(mMap []map[string]interface{}, fn, email, id string, isfile, isHen
 				}
 				xf.Sheets = xf.Sheets[0:1]
 			} else if dataType == 2 {
+
 				sh := xf.Sheets[1]
 				if isfile {
 					cell := sh.Rows[0].AddCell()
@@ -1252,6 +1253,40 @@ func GetXlsxs(mMap []map[string]interface{}, fn, email, id string, isfile, isHen
 					if isfile {
 						row.AddCell().SetValue(v["filetext"])
 					}
+					if NeedFilehrefAppidMap[appid] == true {
+						if v["filehref"] != nil {
+							if filelist, ok := v["filehref"].([]map[string]interface{}); ok {
+								index := 0
+								for _, url := range filelist {
+									//if urlMap, ok := url.(map[string]interface{}); ok {
+									if url["url"] != nil {
+										if FilterFilehrefAppidMap[appid] {
+											if strings.Contains(url["url"].(string), "jy-datafile.oss-cn-beijing.aliyuncs.com") {
+												if index > 0 {
+													cell := row.AddCell()
+													//cell.SetStyle(style)
+													cell.SetValue(url["url"])
+												} else {
+													row.AddCell().SetValue(url["url"])
+												}
+												index++
+											}
+										} else {
+											if index > 0 {
+												cell := row.AddCell()
+												//cell.SetStyle(style)
+												cell.SetValue(url["url"])
+											} else {
+												row.AddCell().SetValue(url["url"])
+											}
+											index++
+										}
+									}
+									//}
+								}
+							}
+						}
+					}
 				}
 				xf.Sheets = xf.Sheets[1:2]
 			} else if dataType == 3 {

+ 6 - 0
src/main.go

@@ -78,6 +78,12 @@ func init() {
 	for _, v := range util.Sysconfig["need_projectid_appid"].([]interface{}) {
 		history.NeedProjectidAppidMap[v.(string)] = true
 	}
+	for _, v := range util.Sysconfig["filter_filehref_appid"].([]interface{}) {
+		history.FilterFilehrefAppidMap[v.(string)] = true
+	}
+	for _, v := range util.Sysconfig["need_filehref_appid"].([]interface{}) {
+		history.NeedFilehrefAppidMap[v.(string)] = true
+	}
 }
 
 func main() {

+ 37 - 3
src/service/second_push.go

@@ -287,7 +287,7 @@ func (s *SecondPush) SecondPushTask() {
 					log.Println("查询数据为空")
 				} else {
 					log.Println(len(xlsxArr))
-					GetXlsxs(xlsxArr, customer_name, email, s_pushid)
+					GetXlsxs(xlsxArr, customer_name, email, s_pushid, qu.ObjToString(c["s_appid"]))
 					go UpdateHistoryState(2, s_pushid, len(xlsxArr))
 					s.ServeJson(map[string]interface{}{
 						"status": true,
@@ -444,7 +444,7 @@ func (s *SecondPush) HistoryRuleEdit() {
 	}
 }
 
-func GetXlsxs(mMap []map[string]interface{}, fn, email, id string) {
+func GetXlsxs(mMap []map[string]interface{}, fn, email, id, appid string) {
 	if id != "" {
 		query := bson.M{
 			"_id": bson.ObjectIdHex(id),
@@ -570,6 +570,40 @@ func GetXlsxs(mMap []map[string]interface{}, fn, email, id string) {
 						row.AddCell().SetValue(v["company_email"])
 						ids := SE.EncodeString(qu.ObjToString(v["id"]))
 						row.AddCell().SetValue(ids)
+						if history.NeedFilehrefAppidMap[appid] == true {
+							if v["filehref"] != nil {
+								if filelist, ok := v["filehref"].([]interface{}); ok {
+									index := 0
+									for _, url := range filelist {
+										if urlMap, ok := url.(map[string]interface{}); ok {
+											if urlMap["url"] != nil {
+												if history.FilterFilehrefAppidMap[appid] {
+													if strings.Contains(urlMap["url"].(string), "jy-datafile.oss-cn-beijing.aliyuncs.com") {
+														if index > 0 {
+															cell := row.AddCell()
+															//cell.SetStyle(style)
+															cell.SetValue(urlMap["url"])
+														} else {
+															row.AddCell().SetValue(urlMap["url"])
+														}
+														index++
+													}
+												} else {
+													if index > 0 {
+														cell := row.AddCell()
+														//cell.SetStyle(style)
+														cell.SetValue(urlMap["url"])
+													} else {
+														row.AddCell().SetValue(urlMap["url"])
+													}
+													index++
+												}
+											}
+										}
+									}
+								}
+							}
+						}
 					}
 				}
 				//xf.Sheets = xf.Sheets[1:2]
@@ -728,7 +762,7 @@ func GetXlsxs(mMap []map[string]interface{}, fn, email, id string) {
 						row.AddCell().SetValue(v["projectname"]) //项目名称
 						row.AddCell().SetValue(v["buyer"])       //采购单位
 						row.AddCell().SetValue(v["buyer_type"])  //采购单位类别---私有标签tagname
-						if v["bidamount"] != nil {               //中标金额
+						if v["bidamount"] != nil { //中标金额
 							row.AddCell().SetFloat(qu.Float64All(v["bidamount"]))
 						} else {
 							row.AddCell()

BIN
src/web/res/fields.xlsx