Browse Source

修复 项目预测 bug

wcc 1 year ago
parent
commit
ab5bdac196
5 changed files with 164 additions and 675 deletions
  1. 43 24
      createEsIndex/bidding_es.go
  2. 6 0
      createEsIndex/es_test.go
  3. 60 1
      createEsIndex/go.mod
  4. 54 650
      createEsIndex/go.sum
  5. 1 0
      createEsIndex/init.go

+ 43 - 24
createEsIndex/bidding_es.go

@@ -178,7 +178,7 @@ func biddingTask(mapInfo map[string]interface{}) {
 	//log.Info("bidding index es over", zap.Any("es", next), zap.String("mapinfo", string(datas)))
 }
 
-//biddingAllTask 补充存量数据
+// biddingAllTask 补充存量数据
 func biddingAllTask(mapInfo map[string]interface{}) {
 	defer util.Catch()
 
@@ -270,7 +270,7 @@ func biddingAllTask(mapInfo map[string]interface{}) {
 
 }
 
-//biddingAllDataTask 处理配置文件的存量数据
+// biddingAllDataTask 处理配置文件的存量数据
 func biddingAllDataTask() {
 	type Biddingall struct {
 		Coll  string
@@ -698,37 +698,51 @@ func getFileText(tmp map[string]interface{}) (filetext string) {
 func YuceEndtime(tmp map[string]interface{}) {
 	flag := false
 	flag2 := false
+	falseOld := false
+	scopeOld := []string{"服务采购_法律咨询", "服务采购_会计", "服务采购_物业", "服务采购_审计", "服务采购_安保", "服务采购_仓储物流",
+		"服务采购_广告宣传印刷"}
 	scope := []string{"信息技术_运维服务", "信息技术_软件开发", "信息技术_系统集成及安全", "信息技术_其他"}
 	titles := []string{"短信服务", "短信发送服务"}
 	details := []string{"短信发送服务", "短信服务平台", "短信服务项目"}
 	subscopeclass := util.ObjToString(tmp["s_subscopeclass"])
-	//先判断满足 s_subscopeclass 条件
+
+	//1.先判断老的
+	for _, v := range scopeOld {
+		if strings.Contains(subscopeclass, v) {
+			falseOld = true
+			break
+		}
+	}
+	//2.判断满足 s_subscopeclass 条件
 	for _, v := range scope {
 		if strings.Contains(subscopeclass, v) {
 			flag = true
 			break
 		}
 	}
-	//满足 s_subscopeclass ,再去判断title  detail
-	if flag {
-		title := util.ObjToString(tmp["title"])
-		for _, v := range titles {
-			if strings.Contains(title, v) {
-				flag2 = true
-			}
-		}
-		if !flag2 {
-			detail := util.ObjToString(tmp["detail"])
-			for _, v := range details {
-				if strings.Contains(detail, v) {
+	//不满足旧的,判断新的规则
+	if !falseOld {
+		//满足 s_subscopeclass ,再去判断title  detail
+		if flag {
+			title := util.ObjToString(tmp["title"])
+			for _, v := range titles {
+				if strings.Contains(title, v) {
 					flag2 = true
 				}
 			}
+			if !flag2 {
+				detail := util.ObjToString(tmp["detail"])
+				for _, v := range details {
+					if strings.Contains(detail, v) {
+						flag2 = true
+					}
+				}
+			}
 		}
-	}
 
-	if !flag2 {
-		return
+		if !flag2 {
+			return
+		}
 	}
 
 	subtype := util.ObjToString(tmp["subtype"])
@@ -737,7 +751,7 @@ func YuceEndtime(tmp map[string]interface{}) {
 		yucestarttime, yuceendtime := int64(0), int64(0)
 		// 项目周期中
 		if util.ObjToString(tmp["projectperiod"]) != "" {
-			dateStr := date1.FindStringSubmatch(util.ObjToString(tmp["projectperiod"]))
+			dateStr := date1.FindAllString(util.ObjToString(tmp["projectperiod"]), -1)
 			if len(dateStr) == 2 {
 				sdate := FormatDateStr(dateStr[0])
 				edate := FormatDateStr(dateStr[1])
@@ -779,11 +793,16 @@ func FormatDateStr(ds string) int64 {
 	ds = strings.Replace(ds, "日", "", -1)
 	ds = strings.Replace(ds, "/", "-", -1)
 	ds = strings.Replace(ds, ".", "-", -1)
-
+	layout1 := "2006-1-2"
 	location, err := time.ParseInLocation(util.Date_Short_Layout, ds, time.Local)
 	if err != nil {
-		log.Error("FormatDateStr", zap.Error(err))
-		return 0
+		location, err := time.ParseInLocation(layout1, ds, time.Local)
+		if err != nil {
+			log.Error("FormatDateStr", zap.Error(err))
+			return 0
+		} else {
+			return location.Unix()
+		}
 	} else {
 		return location.Unix()
 	}
@@ -818,7 +837,7 @@ func UdpMethod(id string) {
 	_ = UdpClient.WriteUdp(datas, udp.OP_TYPE_DATA, JyUdpAddr)
 }
 
-//MatchService 针对中国招标网,匹配关键词打标签,object_type,货物、服务、工程,jsondata.item
+// MatchService 针对中国招标网,匹配关键词打标签,object_type,货物、服务、工程,jsondata.item
 func MatchService(tmp map[string]interface{}) (res string) {
 	if jsondata, ok := tmp["jsondata"]; ok {
 		if da, ok := jsondata.(map[string]interface{}); ok {
@@ -836,7 +855,7 @@ func MatchService(tmp map[string]interface{}) (res string) {
 	return
 }
 
-//dealPackage 处理package 字段
+// dealPackage 处理package 字段
 func dealPackage(tmp map[string]interface{}) (newpackages []map[string]interface{}) {
 	package1, ok1 := tmp["package"]
 	s_winner, ok2 := tmp["s_winner"]

+ 6 - 0
createEsIndex/es_test.go

@@ -288,3 +288,9 @@ func parseDateString(dateString string) (int64, error) {
 
 	return 0, fmt.Errorf("unrecognized date format")
 }
+
+func TestYuceEndtime(t *testing.T) {
+	data, _ := MgoB.FindById("bidding", "657ac63c6977356f55773c3e", nil)
+	YuceEndtime(*data)
+	fmt.Println(data)
+}

+ 60 - 1
createEsIndex/go.mod

@@ -1,13 +1,72 @@
 module esindex
 
-go 1.16
+go 1.18
 
 require (
 	github.com/aliyun/aliyun-oss-go-sdk v2.2.5+incompatible
+	github.com/nats-io/nats.go v1.31.0
 	github.com/olivere/elastic/v7 v7.0.32
 	github.com/robfig/cron v1.2.0
 	github.com/spf13/viper v1.15.0
 	go.mongodb.org/mongo-driver v1.10.2
 	go.uber.org/zap v1.23.0
+	jygit.jydev.jianyu360.cn/BP/jynats v0.0.0-20231206094405-2ff9da3175bc
 	jygit.jydev.jianyu360.cn/data_processing/common_utils v0.0.0-20231122020338-4956718a7e9e
 )
+
+require (
+	github.com/BurntSushi/toml v1.2.0 // indirect
+	github.com/PuerkitoBio/goquery v1.8.0 // indirect
+	github.com/andybalholm/cascadia v1.3.1 // indirect
+	github.com/clbanning/mxj/v2 v2.7.0 // indirect
+	github.com/dchest/captcha v1.0.0 // indirect
+	github.com/fatih/color v1.15.0 // indirect
+	github.com/fsnotify/fsnotify v1.7.0 // indirect
+	github.com/go-logr/logr v1.2.4 // indirect
+	github.com/go-logr/stdr v1.2.2 // indirect
+	github.com/go-sql-driver/mysql v1.6.0 // indirect
+	github.com/gogf/gf/v2 v2.5.7 // indirect
+	github.com/golang/snappy v0.0.1 // indirect
+	github.com/gorilla/websocket v1.5.0 // indirect
+	github.com/grokify/html-strip-tags-go v0.0.1 // indirect
+	github.com/hashicorp/hcl v1.0.0 // indirect
+	github.com/josharian/intern v1.0.0 // indirect
+	github.com/klauspost/compress v1.17.0 // indirect
+	github.com/magiconair/properties v1.8.7 // indirect
+	github.com/mailru/easyjson v0.7.7 // indirect
+	github.com/mattn/go-colorable v0.1.13 // indirect
+	github.com/mattn/go-isatty v0.0.20 // indirect
+	github.com/mattn/go-runewidth v0.0.15 // indirect
+	github.com/mitchellh/mapstructure v1.5.0 // indirect
+	github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
+	github.com/nats-io/nkeys v0.4.5 // indirect
+	github.com/nats-io/nuid v1.0.1 // indirect
+	github.com/olekukonko/tablewriter v0.0.5 // indirect
+	github.com/pelletier/go-toml/v2 v2.0.6 // indirect
+	github.com/pkg/errors v0.9.1 // indirect
+	github.com/rivo/uniseg v0.4.4 // indirect
+	github.com/spf13/afero v1.9.3 // indirect
+	github.com/spf13/cast v1.5.0 // indirect
+	github.com/spf13/jwalterweatherman v1.1.0 // indirect
+	github.com/spf13/pflag v1.0.5 // indirect
+	github.com/subosito/gotenv v1.4.2 // indirect
+	github.com/xdg-go/pbkdf2 v1.0.0 // indirect
+	github.com/xdg-go/scram v1.1.1 // indirect
+	github.com/xdg-go/stringprep v1.0.3 // indirect
+	github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
+	go.opentelemetry.io/otel v1.14.0 // indirect
+	go.opentelemetry.io/otel/sdk v1.14.0 // indirect
+	go.opentelemetry.io/otel/trace v1.14.0 // indirect
+	go.uber.org/atomic v1.9.0 // indirect
+	go.uber.org/multierr v1.8.0 // indirect
+	golang.org/x/crypto v0.14.0 // indirect
+	golang.org/x/net v0.17.0 // indirect
+	golang.org/x/sync v0.1.0 // indirect
+	golang.org/x/sys v0.13.0 // indirect
+	golang.org/x/text v0.13.0 // indirect
+	golang.org/x/time v0.1.0 // indirect
+	gopkg.in/ini.v1 v1.67.0 // indirect
+	gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect
+	gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
+	gopkg.in/yaml.v3 v3.0.1 // indirect
+)

File diff suppressed because it is too large
+ 54 - 650
createEsIndex/go.sum


+ 1 - 0
createEsIndex/init.go

@@ -136,6 +136,7 @@ func InitEs() {
 		Password: config.Conf.DB.Es.Password,
 	}
 	Es.InitElasticSize()
+	log.Info("InitEs", zap.String("阿里云", config.Conf.DB.Es.Addr))
 
 	if config.Conf.DB.Es.Addr == "" {
 		log.Error("InitEs", zap.String("ES", "地址或者数据库为空"))

Some files were not shown because too many files changed in this diff