Browse Source

Merge branch 'dev/v4.8.78_dx' of qmx/jy into feature/v4.8.78

duxin 1 year ago
parent
commit
ed5d03a5e3

+ 1 - 4
src/config.json

@@ -448,8 +448,5 @@
   "hotSubjectMatter": "A4纸,安全标志,安全挡板,安全隔离网,安全网,办公耗材,办公家具,办公设备,办公椅,办公用房,办公用品,办公桌,保护装置,保密柜,笔记本,笔记本电脑,变压器,仓库,插线板,充电桩,触控一体机,传感器,打印机,打印机耗材,打印设备,档案袋,档案盒,道路工程,地铁,电池,电缆,电流互感器,电梯,电线,订书机,订书针,对讲机,多功能一体机,多媒体设备,发电机,防冻液,防护栏杆,防护门,防护棚,防雷设施,防水工程,服务器,服装,复印机,复印纸,钢板,钢结构,钢筋,工作服,工作站,公路,公用工程,固体胶,光伏,光盘,航标灯,回形针,机房空调,机柜,机油,鸡蛋,计算机,记号笔,记事本,继电器,家具,监测仪,监视器,检测报告,检测仪器,剪刀,建筑工程,交换机,交通设施,胶带,胶水,脚手架,井架,警示灯,救护车,救生设施,刻录机,空调,空气调节器,垃圾袋,垃圾桶,冷却塔,冷水机组,楼层呼唤器,路灯,绿化工程,毛巾,美工刀,门禁,密集架,灭火器,抹布,墨盒,逆变器,牛皮纸,配电箱,喷壶,起重机,汽油,桥梁,热泵机组,热水器,弱电系统,扫描仪,摄像头,生活用房,食堂,市政工程,双面胶,水电站,水桶,宿舍,碎纸机,台式机,太阳能,碳粉,天然气,投影仪,图书,土石方,拖把,挖掘机,网线,文件袋,文件柜,无人机,无线电,硒鼓,洗洁精,洗手液,洗衣粉,显示屏,橡皮,消防立管,消防器材,消防水泵,消防箱,新能源,蓄电池,液晶显示器,医疗器械,医疗设备,移动工作站,移动硬盘,预埋钢板,园林工程,纸杯,中性笔,桩基,装修工程",
   "biddingRelatesLevel": 0,
   "ipInitAuthentication": "qwertyuiopzxcvbnm1234567890asdfghjkl",
-  "node": 1,
-  "keywordRestrict": 100,
-  "buyerRestrict": 100,
-  "winnerRestrict": 100
+  "node": 1
 }

+ 2 - 0
src/jfw/config/config.go

@@ -21,6 +21,7 @@ var (
 	//seo.josn 配置文件中的版本号,可以动态更新
 	Seoconfig_Version    string
 	Sysconfig            map[string]interface{}
+	ExportConfig         map[string]interface{}
 	Seoconfig            map[string]interface{}
 	WeixinConfig         map[string]interface{}
 	PhoneFilterConfig    map[string]interface{}
@@ -49,6 +50,7 @@ type entnichePcConf struct {
 func init() {
 	g.Cfg().GetAdapter().(*gcfg.AdapterFile).SetFileName("config.yaml")
 	util.ReadConfig(&Sysconfig)
+	util.ReadConfig("./export.json", &ExportConfig)
 	IpInit()
 	//ClickhouseInit()
 	//log.Println("sysconfig:", Sysconfig)

+ 8 - 0
src/jfw/export.json

@@ -0,0 +1,8 @@
+{
+  "exportLimit": {
+    "wordsLimit": 100,
+    "countLimit": 300,
+    "buyerLimit": 100,
+    "winnerLimit": 100
+  }
+}

+ 45 - 7
src/jfw/front/dataExport.go

@@ -145,7 +145,6 @@ func (d *DataExport) SieveData() {
 		subTypeArr = strings.Split(subType, ",")
 		log.Println("subTypeArr", subTypeArr)
 	}
-	log.Println("keywordParam", keyword)
 	if keyword != "" {
 		err := json.Unmarshal([]byte(keyword), &keywordList)
 		if err != nil {
@@ -190,14 +189,52 @@ func (d *DataExport) SieveData() {
 			selectType = strings.Replace(strings.Join(detail, ","), "detail", "title,detail", -1)
 		}
 	}
-	if len(keywordList) > util.IntAllDef(config.Sysconfig["keywordRestrict"], 100) {
-		keywordList = keywordList[:util.IntAllDef(config.Sysconfig["keywordRestrict"], 100)]
+
+	exportLimit := util.StructToMapMore(config.ExportConfig["exportLimit"])
+	wordsLimit := util.IntAllDef(exportLimit["wordsLimit"], 100)
+	countLimit := util.IntAllDef(exportLimit["countLimit"], 300)
+	buyerLimit := util.IntAllDef(exportLimit["buyerLimit"], 100)
+	winnerLimit := util.IntAllDef(exportLimit["winnerLimit"], 100)
+
+	var count int
+	for k, kw := range keywordList {
+		if kw.Keyword != "" {
+			count++
+		}
+		count += len(kw.Appended)
+		count += len(kw.Exclude)
+		if len([]rune(kw.Keyword)) > wordsLimit {
+			keywordList[k].Keyword = util.SubString(kw.Keyword, 0, wordsLimit)
+		}
+
+		for k1, ad := range kw.Appended {
+			if len([]rune(ad)) > wordsLimit {
+				keywordList[k].Appended[k1] = util.SubString(ad, 0, wordsLimit)
+			}
+		}
+		for k1, el := range kw.Exclude {
+			if len([]rune(el)) > wordsLimit {
+				keywordList[k].Exclude[k1] = util.SubString(el, 0, wordsLimit)
+			}
+		}
 	}
-	if len(buyerArr) > util.IntAllDef(config.Sysconfig["buyerRestrict"], 100) {
-		buyerArr = buyerArr[:util.IntAllDef(config.Sysconfig["buyerRestrict"], 100)]
+	if count > countLimit {
+		d.ServeJson(map[string]interface{}{
+			"error_code": -1,
+			"error_msg":  fmt.Sprintf("关键词信息超过上限%d", countLimit),
+		})
 	}
-	if len(winnerArr) > util.IntAllDef(config.Sysconfig["winnerRestrict"], 100) {
-		winnerArr = winnerArr[:util.IntAllDef(config.Sysconfig["winnerRestrict"], 100)]
+	if len(buyerArr) > buyerLimit {
+		d.ServeJson(map[string]interface{}{
+			"error_code": -1,
+			"error_msg":  fmt.Sprintf("采购单位超过上限%d", buyerLimit),
+		})
+	}
+	if len(winnerArr) > winnerLimit {
+		d.ServeJson(map[string]interface{}{
+			"error_code": -1,
+			"error_msg":  fmt.Sprintf("中标单位超过上限%d", winnerLimit),
+		})
 	}
 	sieveCondition := map[string]interface{}{
 		"publishtime": publishtime,
@@ -250,6 +287,7 @@ func (d *DataExport) SieveData() {
 				}
 			}
 		}
+
 		list := dataexport.FormatExportData(public.Mgo_Ent, &res_screen, config.Sysconfig["webdomain"].(string), dataType, true)
 		/*if msgCount > 20000 {
 			msgCount = 20000

+ 45 - 7
src/jfw/front/wx_dataExport.go

@@ -3,6 +3,7 @@ package front
 import (
 	"encoding/json"
 	"errors"
+	"fmt"
 	"jy/src/jfw/config"
 	"jy/src/jfw/wx"
 	"log"
@@ -171,15 +172,45 @@ func (w *WxDataExport) SaveData() error {
 	if winner != "" {
 		winnerArr = strings.Split(winner, ",")
 	}
+	exportLimit := util.StructToMapMore(config.ExportConfig["exportLimit"])
 	if keyWord != "" {
+		countLimit := util.IntAllDef(exportLimit["countLimit"], 300)
+		var count int
+		wordsLimit := util.IntAllDef(exportLimit["wordsLimit"], 100)
 		if json.Unmarshal([]byte(keyWord), &keyWordArr) == nil {
 			for k, v := range keyWordArr {
+				if v.Keyword != "" {
+					count++
+				}
+				if len([]rune(v.Keyword)) > wordsLimit {
+					keyWordArr[k].Keyword = util.SubString(v.Keyword, 0, wordsLimit)
+				}
 				if v.Appended == nil {
 					keyWordArr[k].Appended = []string{}
+				} else {
+					for k1, ad := range v.Appended {
+						if len([]rune(ad)) > wordsLimit {
+							keyWordArr[k].Appended[k1] = util.SubString(ad, 0, wordsLimit)
+						}
+					}
 				}
 				if v.Exclude == nil {
 					keyWordArr[k].Exclude = []string{}
+				} else {
+					for k1, el := range v.Exclude {
+						if len([]rune(el)) > wordsLimit {
+							keyWordArr[k].Exclude[k1] = util.SubString(el, 0, wordsLimit)
+						}
+					}
 				}
+				count += len(v.Appended)
+				count += len(v.Exclude)
+			}
+			if count > countLimit {
+				w.ServeJson(map[string]interface{}{
+					"error_code": -1,
+					"error_msg":  fmt.Sprintf("关键词信息超过上限%d", countLimit),
+				})
 			}
 		} else {
 			log.Println("keyWord param 反序列化异常,查看前后台字段是否对应")
@@ -207,14 +238,21 @@ func (w *WxDataExport) SaveData() error {
 			selectType = strings.Replace(strings.Join(detail, ","), "detail", "title,detail", -1)
 		}
 	}
-	if len(keyWordArr) > util.IntAllDef(config.Sysconfig["keywordRestrict"], 100) {
-		keyWordArr = keyWordArr[:util.IntAllDef(config.Sysconfig["keywordRestrict"], 100)]
-	}
-	if len(buyerArr) > util.IntAllDef(config.Sysconfig["buyerRestrict"], 100) {
-		buyerArr = buyerArr[:util.IntAllDef(config.Sysconfig["buyerRestrict"], 100)]
+
+	buyerLimit := util.IntAllDef(exportLimit["buyerLimit"], 100)
+	winnerLimit := util.IntAllDef(exportLimit["winnerLimit"], 100)
+
+	if len(buyerArr) > buyerLimit {
+		w.ServeJson(map[string]interface{}{
+			"error_code": -1,
+			"error_msg":  fmt.Sprintf("采购单位超过上限%d", buyerLimit),
+		})
 	}
-	if len(winnerArr) > util.IntAllDef(config.Sysconfig["winnerRestrict"], 100) {
-		winnerArr = winnerArr[:util.IntAllDef(config.Sysconfig["winnerRestrict"], 100)]
+	if len(winnerArr) > winnerLimit {
+		w.ServeJson(map[string]interface{}{
+			"error_code": -1,
+			"error_msg":  fmt.Sprintf("中标单位超过上限%d", winnerLimit),
+		})
 	}
 	saveData := map[string]interface{}{
 		"publishtime": publishtime,

+ 45 - 7
src/jfw/modules/app/src/app/front/dataExport.go

@@ -3,6 +3,7 @@ package front
 import (
 	"encoding/json"
 	"errors"
+	"fmt"
 	"jy/src/jfw/modules/app/src/jfw/config"
 	"log"
 	"strings"
@@ -174,19 +175,49 @@ func (w *WxDataExport) SaveData() error {
 	if winner != "" {
 		winnerArr = strings.Split(winner, ",")
 	}
+	exportLimit := util.StructToMapMore(config.ExportConfig["exportLimit"])
 	if keyWord != "" {
+		countLimit := util.IntAllDef(exportLimit["countLimit"], 300)
+		var count int
+		wordsLimit := util.IntAllDef(exportLimit["wordsLimit"], 100)
 		err := json.Unmarshal([]byte(keyWord), &keyWordArr)
 		if err != nil {
 			log.Println("keyWord param 反序列化异常,查看前后台字段是否对应")
 		} else {
 			log.Println("keyWordArr", len(keyWordArr), keyWordArr)
 			for k, v := range keyWordArr {
+				if v.Keyword != "" {
+					count++
+				}
+				if len([]rune(v.Keyword)) > wordsLimit {
+					keyWordArr[k].Keyword = util.SubString(v.Keyword, 0, wordsLimit)
+				}
 				if v.Appended == nil {
 					keyWordArr[k].Appended = []string{}
+				} else {
+					for k1, ad := range v.Appended {
+						if len([]rune(ad)) > wordsLimit {
+							keyWordArr[k].Appended[k1] = util.SubString(ad, 0, wordsLimit)
+						}
+					}
 				}
 				if v.Exclude == nil {
 					keyWordArr[k].Exclude = []string{}
+				} else {
+					for k1, el := range v.Exclude {
+						if len([]rune(el)) > wordsLimit {
+							keyWordArr[k].Exclude[k1] = util.SubString(el, 0, wordsLimit)
+						}
+					}
 				}
+				count += len(v.Appended)
+				count += len(v.Exclude)
+			}
+			if count > countLimit {
+				w.ServeJson(map[string]interface{}{
+					"error_code": -1,
+					"error_msg":  fmt.Sprintf("关键词信息超过上限%d", countLimit),
+				})
 			}
 		}
 	}
@@ -212,14 +243,21 @@ func (w *WxDataExport) SaveData() error {
 			selectType = strings.Replace(strings.Join(detail, ","), "detail", "title,detail", -1)
 		}
 	}
-	if len(keyWordArr) > util.IntAllDef(config.Seoconfig["keywordRestrict"], 100) {
-		keyWordArr = keyWordArr[:util.IntAllDef(config.Sysconfig["keywordRestrict"], 100)]
-	}
-	if len(buyerArr) > util.IntAllDef(config.Sysconfig["buyerRestrict"], 100) {
-		buyerArr = buyerArr[:util.IntAllDef(config.Sysconfig["buyerRestrict"], 100)]
+
+	buyerLimit := util.IntAllDef(exportLimit["buyerLimit"], 100)
+	winnerLimit := util.IntAllDef(exportLimit["winnerLimit"], 100)
+
+	if len(buyerArr) > buyerLimit {
+		w.ServeJson(map[string]interface{}{
+			"error_code": -1,
+			"error_msg":  fmt.Sprintf("采购单位超过上限%d", buyerLimit),
+		})
 	}
-	if len(winnerArr) > util.IntAllDef(config.Sysconfig["winnerRestrict"], 100) {
-		winnerArr = winnerArr[:util.IntAllDef(config.Sysconfig["winnerRestrict"], 100)]
+	if len(winnerArr) > winnerLimit {
+		w.ServeJson(map[string]interface{}{
+			"error_code": -1,
+			"error_msg":  fmt.Sprintf("中标单位超过上限%d", winnerLimit),
+		})
 	}
 	saveData := map[string]interface{}{
 		"publishtime": publishtime,

+ 5 - 0
src/jfw/modules/app/src/app/tag/msg.go

@@ -15,6 +15,11 @@ func Msg(mtype, key string) string {
 	return readproperty(mtype, key)
 }
 
+// 从json配置文件中读取值
+func Export() map[string]interface{} {
+	return config.ExportConfig
+}
+
 func Cdns(host, mtype, key string) string {
 	if host == "" {
 		return readproperty(mtype, key)

+ 1 - 4
src/jfw/modules/app/src/config.json

@@ -252,8 +252,5 @@
     "projecttype": true,
     "approvecity": true
   },
-  "ipInitAuthentication": "qwertyuiopzxcvbnm1234567890asdfghjkl",
-  "keywordRestrict": 100,
-  "buyerRestrict": 100,
-  "winnerRestrict": 100
+  "ipInitAuthentication": "qwertyuiopzxcvbnm1234567890asdfghjkl"
 }

+ 8 - 0
src/jfw/modules/app/src/export.json

@@ -0,0 +1,8 @@
+{
+  "exportLimit": {
+    "wordsLimit": 100,
+    "countLimit": 300,
+    "buyerLimit": 100,
+    "winnerLimit": 100
+  }
+}

+ 2 - 0
src/jfw/modules/app/src/jfw/config/config.go

@@ -15,6 +15,7 @@ import (
 var (
 	// Seoconfig_Version seo.josn 配置文件中的版本号,可以动态更新
 	Seoconfig_Version string
+	ExportConfig      map[string]interface{}
 	// Seoconfig_Mod_Version Seoconfig_Version 作为固定版本号 除非大版本更新需要改动,其他都更改Seoconfig_Mod_Version  王山  2020/06/11
 	Seoconfig_Mod_Version string
 	Seoconfig_Cdns        map[string]interface{}
@@ -30,6 +31,7 @@ var (
 func init() {
 	g.Cfg().GetAdapter().(*gcfg.AdapterFile).SetFileName("config.yaml")
 	util.ReadConfig(&Sysconfig)
+	util.ReadConfig("./export.json", &ExportConfig)
 	IpInit()
 	mails, _ := Sysconfig["mail"].([]interface{})
 	mailConfigArrMap := util.ObjArrToMapArr(mails)

+ 1 - 1
src/jfw/modules/app/src/main.go

@@ -68,7 +68,7 @@ func initXweb() {
 	xweb.RootApp().AppConfig.CacheTemplates = Sysconfig["cacheflag"].(bool)
 	xweb.RootApp().AddTmplVar("Msg", tag.Msg)
 	xweb.RootApp().AddTmplVar("Cdns", tag.Cdns)
-
+	xweb.RootApp().AddTmplVar("Export", tag.Export)
 	xweb.RootApp().AddTmplVar("Ad", tag.Ad)
 	xweb.RootApp().AddTmplVar("SafeUrl", tag.SafeUrl)
 	xweb.RootApp().Logger.SetOutputLevel(1) //输出日志,改为4则不输出任何日志

+ 1 - 0
src/jfw/tag/a_init.go

@@ -15,4 +15,5 @@ func init() {
 	xweb.RootApp().AddTmplVar("ParseHtml", ParseHtml)
 	xweb.RootApp().AddTmplVar("ParseHtmlCss", ParseHtmlCss)
 	xweb.RootApp().AddTmplVar("ParseHtmlAttr", ParseHtmlAttr)
+	xweb.RootApp().AddTmplVar("Export", Export)
 }

+ 6 - 3
src/jfw/tag/msg.go

@@ -10,12 +10,16 @@ import (
 	util "app.yhyue.com/moapp/jybase/common"
 )
 
-//从json配置文件中读取值
+// 从json配置文件中读取值
+func Export() map[string]interface{} {
+	return config.ExportConfig
+}
+
+// 从json配置文件中读取值
 func Msg(mtype, key string) string {
 	return readproperty(mtype, key)
 }
 
-//
 func DateTip(date2 int64) (timedate string) {
 	timedate = "30秒前"
 	date1 := time.Now().Unix()
@@ -50,7 +54,6 @@ func DateTip(date2 int64) (timedate string) {
 	return
 }
 
-//
 func readproperty(mtype, key string) string {
 	switch mtype {
 	case "seo":