Browse Source

Merge branch 'dev3.4' of http://192.168.3.207:10080/qmx/jy-data-extract into dev3.4

apple 5 years ago
parent
commit
a4cd1cc37c

+ 5 - 5
fullproject/src_v1/config.json

@@ -2,12 +2,12 @@
     "loadStart": 0,
 	"validdays":150,
     "statusdays": 7,
-	"mongodbServers": "192.168.3.207:27092",
+	"mongodbServers": "192.168.3.166:27082",
     "mongodbPoolSize": 10,
-    "mongodbName": "extract_kf",
+    "mongodbName": "zhaolongyue",
 	"hints":"publishtime_1",
-    "extractColl": "ceshi_info",
-    "projectColl": "jh_project",
+    "extractColl": "huawei_bidding_all_0110_v2",
+    "projectColl": "huawei_project_0113_v2",
     "backupFlag": false,
     "siteColl": "site",
     "thread": 1,
@@ -15,7 +15,7 @@
         "to": "wangjianghan@topnet.net.cn",
         "api": "http://10.171.112.160:19281/_send/_mail"
     },
-    "udpport": ":1182",
+    "udpport": "1182",
     "nextNode": [
     ]
 }

+ 1 - 2
fullproject/src_v1/init.go

@@ -64,7 +64,6 @@ func init() {
 	ExtractColl = Sysconfig["extractColl"].(string)
 	ProjectColl = Sysconfig["projectColl"].(string)
 	BackupColl = Sysconfig["projectColl"].(string)+"_back"
-	log.Println(BackupColl)
 	SiteColl = Sysconfig["siteColl"].(string)
 	Thread = util.IntAll(Sysconfig["thread"])
 	//NextNode = Sysconfig["nextNode"].([]interface{})
@@ -275,7 +274,7 @@ type ProjectInfo struct {
 	Ids           []string           `json:"ids,omitempty"`
 	Topscopeclass []string           `json:"topscopeclass,omitempty"`
 	Subscopeclass []string           `json:"subscopeclass,omitempty"` //子行业分类
-	Winners       []string           `json:"winners,omitempty"`       //中标人
+	Winners       []string           `json:"s_winner,omitempty"`       //中标人
 	ProjectName   string             `json:"projectname,omitempty"`   //项目名称
 	ProjectCode   string             `json:"projectcode,omitempty"`   //项目代码唯一(纯数字的权重低)
 	ContractCode  string			 `json:"contractcode,omitempty"`  //项目编号

+ 11 - 52
fullproject/src_v1/main.go

@@ -9,7 +9,6 @@ import (
 	"os"
 	"os/signal"
 	"qfw/util"
-	qu "qfw/util"
 	"syscall"
 	"time"
 )
@@ -20,7 +19,7 @@ var (
 	toaddr       = []*net.UDPAddr{} //下节点对象
 	ChSign       = make(chan os.Signal)
 
-	sid, eid string //测试使用
+	sid, eid string 	//测试使用
 )
 
 func init() {
@@ -59,7 +58,7 @@ func DealSign() {
 	}
 }
 
-func main() {
+func mainT() {
 	//udp跑增量  id段   project
 	//udp跑全量			ql
 	//udp跑历史数据  信息id1,id2/或id段  ls
@@ -78,9 +77,9 @@ func main() {
 }
 
 //测试组人员使用
-func mainT() {
-	//sid = "5dfbd43ce9d1f601e43fa402"
-	//eid = "5e0954b30cf41612e061d0c8"
+func main() {
+	//sid = "5649a0fcaf5374672e005704"
+	//eid = "5e169e5250b5ea296ec896f0"
 
 	flag.StringVar(&sid, "sid", "", "开始id")
 	flag.StringVar(&eid, "eid", "", "结束id")
@@ -91,8 +90,8 @@ func mainT() {
 		log.Println("sid, eid参数不能为空")
 		os.Exit(0)
 	}
-	mapinfo["gtid"] = qu.StringTOBsonId(sid)
-	mapinfo["lteid"] = qu.StringTOBsonId(eid)
+	mapinfo["gtid"] = sid
+	mapinfo["lteid"] = eid
 	mapinfo["stype"] = "ql"
 	mapinfo["ip"] = "127.0.0.1"
 	mapinfo["port"] = Sysconfig["udpport"]
@@ -103,52 +102,12 @@ func mainT() {
 		}
 	}
 	P_QL.loadSite()
-	task(mapinfo)
-	SingleThread <- true
+	P_QL.currentType = mapinfo["stype"].(string)
+	P_QL.pici = time.Now().Unix()
+	P_QL.taskQl(mapinfo)
 	time.Sleep(20 * time.Second)
 }
 
-func task(mapInfo map[string]interface{}) {
-	SingleThread <- true
-	tasktype, _ := mapInfo["stype"].(string)
-	log.Println("tasktype:", tasktype)
-	switch tasktype {
-	case "ql": //全量合并
-		go func() {
-			defer func() {
-				<-SingleThread
-			}()
-			P_QL.currentType = tasktype
-			P_QL.pici = time.Now().Unix()
-			P_QL.taskQl(mapInfo)
-		}()
-	case "project": //增量合并,未抽取到项目名称或项目编号的不合并  bidding中mergestatus 1已合并 2字段问题不合并 3历史待合并
-		//合同、验收公告在6个月内查询不到可扩展到两年
-		go func() {
-			defer func() {
-				<-SingleThread
-			}()
-			P_QL.currentType = tasktype
-			P_QL.pici = time.Now().Unix()
-			P_QL.taskZl(mapInfo)
-		}()
-	case "updateInfo": //招标字段变更
-		go func() {
-			defer func() {
-				<-SingleThread
-			}()
-			P_QL.currentType = tasktype
-			P_QL.pici = time.Now().Unix()
-			P_QL.taskUpdateInfo(mapInfo)
-		}()
-	case "history": //历史数据合并,暂时不写
-		go func() {
-			defer func() {
-				<-SingleThread
-			}()
-		}()
-	}
-}
 
 //udp调用信号
 func processUdpMsg(act byte, data []byte, ra *net.UDPAddr) {
@@ -188,7 +147,7 @@ func processUdpMsg(act byte, data []byte, ra *net.UDPAddr) {
 					P_QL.pici = time.Now().Unix()
 					P_QL.taskZl(mapInfo)
 				}()
-			case "updateInfo": //招标字段变更
+			case "updateInfo":		//招标字段变更
 				go func() {
 					defer func() {
 						<-SingleThread

+ 29 - 25
fullproject/src_v1/project.go

@@ -176,8 +176,8 @@ func (p *ProjectTask) startProjectMerge(info *Info, tmp map[string]interface{})
 
 			ex := 0
 			resArr := []*ProjectInfo{}
-			for _, res := range resN {
-				choose, e := p.CompareStatus(resN[0], info)
+			for i, res := range resN {
+				choose, e := p.CompareStatus(resN[i], info)
 				if !choose {
 					ex = e
 					resArr = append(resArr, res)
@@ -186,6 +186,7 @@ func (p *ProjectTask) startProjectMerge(info *Info, tmp map[string]interface{})
 			if len(resArr) > 0 {
 				bFindProject = true
 				findPid = resArr[0].Id.Hex()
+				p.UpdateProject(tmp, info, resArr[0], kv+1, resArr[0].comStr, ex)
 				for k2, bv := range []int{bpn, bpc, bptc, bpb} {
 					if bv > -1 {
 						pids[bv].Arr = append(pids[bv].Arr, findPid)
@@ -210,7 +211,6 @@ func (p *ProjectTask) startProjectMerge(info *Info, tmp map[string]interface{})
 									resArr[0].MPC = append(resArr[0].MPC, qu.If(k2 == 1, info.ProjectCode, info.PTC).(string))
 								}
 							}
-
 						} else {
 							if resArr[0].Buyer == "" {
 								resArr[0].Buyer = info.Buyer
@@ -218,7 +218,6 @@ func (p *ProjectTask) startProjectMerge(info *Info, tmp map[string]interface{})
 						}
 					}
 				}
-				p.UpdateProject(tmp, info, resArr[0], kv+1, resArr[0].comStr, ex)
 			} else {
 				bFindProject = false
 				findPid = ""
@@ -506,12 +505,11 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
 	bt := qu.ObjToString(tmp["toptype"])
 	bs := qu.ObjToString(tmp["subtype"])
 	p.mapBidLock.Lock()
+	set["bidtype"] = bidtype[bs]
 	if bt == "招标" {
 		set["projectscope"] = qu.ObjToString(tmp["projectscope"])
-		set["bidtype"] = bidtype[bs]
 		set["bidstatus"] = bs
 	}else {
-		set["bidtype"] = bt
 		if bidstatus[bs] != "" {
 			set["bidstatus"] = thisinfo.SubType
 		} else if tmp["infoformat"] == 2 {
@@ -522,7 +520,8 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
 	}
 	p.mapBidLock.Unlock()
 
-	p1, pkg := p.NewCachePinfo(pId, thisinfo, bt)
+	pkg := PackageFormat(thisinfo, nil)
+	p1 := p.NewCachePinfo(pId, thisinfo, bt, pkg)
 	if len(thisinfo.Subscopeclass) > 0 {
 		s_subscopeclass := strings.Join(thisinfo.Subscopeclass, ",")
 		set["s_subscopeclass"] = s_subscopeclass
@@ -567,6 +566,7 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
 			"$set": set,
 		},
 	}
+	//log.Println(set)
 	return pId.Hex(), &p1
 }
 
@@ -614,11 +614,7 @@ func (p *ProjectTask) PushListInfo(tmp map[string]interface{}, infoid string) bs
 }
 
 //生成存放在内存中的对象
-func (p *ProjectTask) NewCachePinfo(id primitive.ObjectID, thisinfo *Info, bidtype string) (ProjectInfo, map[string]interface{}) {
-	pkg := map[string]interface{}{}
-	if thisinfo.HasPackage {
-		pkg = PackageFormat(thisinfo, nil)
-	}
+func (p *ProjectTask) NewCachePinfo(id primitive.ObjectID, thisinfo *Info, bidtype string, pkg map[string]interface{}) ProjectInfo {
 	p1 := ProjectInfo{
 		Id:            id,
 		Ids:           []string{thisinfo.Id},
@@ -649,7 +645,7 @@ func (p *ProjectTask) NewCachePinfo(id primitive.ObjectID, thisinfo *Info, bidty
 	if thisinfo.LenPTC > 5 {
 		p1.MPC = append(p1.MPC, thisinfo.PTC)
 	}
-	return p1, pkg
+	return p1
 }
 
 //更新项目
@@ -683,15 +679,16 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
 	bt := qu.ObjToString(tmp["toptype"])
 	bs := qu.ObjToString(tmp["subtype"])
 	p.mapBidLock.Lock()
+	if bidtype[bs] != "" {
+		set["bidtype"] = bidtype[bs]
+	}
 	if bt == "招标" {
 		//招标状态,更新projectscope
 		if tmp["projectscope"] != nil {
 			set["projectscope"] = qu.ObjToString(tmp["projectscope"])
 		}
-		set["bidtype"] = bidtype[bs]
 		set["bidstatus"] = bs
 	}else {
-		set["bidtype"] = bt
 		if bidstatus[bs] != "" {
 			set["bidstatus"] = thisinfo.SubType
 		} else if tmp["infoformat"] == 2 {
@@ -807,6 +804,10 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
 	}
 	//winner
 	if len(thisinfo.Winners) > 0 {
+		if len(pInfo.Winners) <= 0 {
+			set["winner"] = tmp["winner"].(string)
+		}
+
 		sort.Strings(pInfo.Winners)
 		for _, k := range thisinfo.Winners {
 			if BinarySearch(pInfo.Winners, k) == -1 {
@@ -944,7 +945,7 @@ func ComparePlace(project *ProjectInfo, info *Info) bool {
 var PackageEle = []string{
 	"origin",
 	"name",
-	"text",
+	//"text",
 	"budget",
 	"winner",
 	"bidamount",
@@ -969,11 +970,8 @@ func packageEle(map1 map[string]interface{}, id string) map[string]interface{} {
 
 func PackageFormat(info *Info, project *ProjectInfo) map[string]interface{} {
 	p1 := map[string]interface{}{}
-	packageCopy := make(map[string]interface{})
-	if project != nil && project.Package != nil {
-		packageCopy = Copy(project.Package).(map[string]interface{})
-	}
-	if packageCopy != nil && len(packageCopy) > 0 {
+	if project != nil && project.Package != nil && len(project.Package) > 0 {
+		packageCopy := Copy(project.Package).(map[string]interface{})
 		p1 = packageCopy
 		for k, v := range info.Package {
 			if v1, ok := v.(map[string]interface{}); ok {
@@ -985,7 +983,8 @@ func PackageFormat(info *Info, project *ProjectInfo) map[string]interface{} {
 				addFlag := false
 				for k1, v3 := range p1 {
 					if v4, ok := v3.([]map[string]interface{}); ok {
-						if qu.ObjToString(v4[0]["origin"]) == qu.ObjToString(v2["origin"]) && qu.ObjToString(v4[0]["name"]) == qu.ObjToString(v2["name"]) {
+						//if qu.ObjToString(v4[0]["origin"]) == qu.ObjToString(v2["origin"]) && qu.ObjToString(v4[0]["name"]) == qu.ObjToString(v2["name"]) {
+						if k1 == k {
 							v4 = append(v4, v2)
 							p1[k1] = v4
 							addFlag = true
@@ -998,8 +997,9 @@ func PackageFormat(info *Info, project *ProjectInfo) map[string]interface{} {
 				}
 			}
 		}
+		p1 = packageCopy
 	} else {
-		for k, v := range packageCopy {
+		for k, v := range info.Package {
 			v1, _ := v.(map[string]interface{})
 			p2 := map[string]interface{}{}
 			p2 = packageEle(v1, info.Id)
@@ -1009,7 +1009,6 @@ func PackageFormat(info *Info, project *ProjectInfo) map[string]interface{} {
 			p1[k] = []map[string]interface{}{p2}
 		}
 	}
-	p1 = packageCopy
 	return p1
 }
 
@@ -1027,7 +1026,12 @@ func CountAmount(project *ProjectInfo, info *Info) {
 				}
 			}
 		}
-		project.Budget = budget
+		if budget == 0 && info.Budget > 0 {
+			budget = info.Budget
+		}
+		if budget > 0 {
+			project.Budget = budget
+		}
 	}else {
 		//招标没有多包
 		k := KeyPackage.FindStringSubmatch(project.ProjectName)

+ 1 - 2
fullproject/src_v1/task.go

@@ -83,7 +83,7 @@ func NewPT() *ProjectTask {
 		mapPc:     make(map[string]*Key, 5000000),
 		mapHref:   make(map[string]string, 1500000),
 		mapSite:   make(map[string]*Site, 1000000),
-		saveSize:  400,
+		saveSize:  100,
 
 		//saveSign:   make(chan bool, 1),
 		//updateSign: make(chan bool, 1),
@@ -377,7 +377,6 @@ func (p *ProjectTask) enter(db, coll string, q map[string]interface{}) {
 	log.Println("start project", q)
 	sess := MongoTool.GetMgoConn()
 	defer MongoTool.DestoryMongoConn(sess)
-
 	infoPool := make(chan map[string]interface{}, 2000)
 	over := make(chan bool)
 	go func() {

+ 3 - 2
src/jy/clear/tonumber.go

@@ -79,6 +79,7 @@ func ObjToFloat(data []interface{}) []interface{} {
 //金额转换
 func ObjToMoney(data []interface{}) []interface{} {
 	isfindUnit := true
+	tmpstr :=(data)[0]
 	ret := capitalMoney(data)[0]
 	if ret.(float64) < float64(10000) || ret.(float64) > float64(50000000000) {
 		ret2, b := numMoney(data)
@@ -98,7 +99,7 @@ func ObjToMoney(data []interface{}) []interface{} {
 			f = f * 10000
 		}
 	}
-	if f == 0 && !moneyUnitRegBool.MatchString(fmt.Sprint(data[0])) {
+	if f == 0 && !moneyUnitRegBool.MatchString(fmt.Sprint(tmpstr)) {
 		data = append(data, false)
 		return data
 	}
@@ -108,7 +109,7 @@ func ObjToMoney(data []interface{}) []interface{} {
 }
 //["中标金额","成交金额","合同金额","中标价","成交价","成交价格","中标(成交)金额","投标报价","中标标价","成交结果"]
 //["0元","零元","0.0万元","¥0元"]
-var moneyUnitRegBool = regexp.MustCompile(`(中标金额|成交金额|合同金额|中标价|成交价|成交价格|中标\(成交\)金额|投标报价|中标标价|成交结果)?[::\s]?(0元|零元|0.0万元|¥0元|0)+`)
+var moneyUnitRegBool = regexp.MustCompile(`(中标金额|成交金额|合同金额|中标价|成交价|成交价格|中标\(成交\)金额|投标报价|中标标价|成交结果)?[::\s]?(0元|零元|0.0万元|¥0元|0)+[\s]?$`)
 //数字金额转换
 func numMoney(data []interface{}) ([]interface{}, bool) {
 	tmp := fmt.Sprintf("%f",data[0])

+ 2 - 8
src/jy/extract/extpackage.go

@@ -63,24 +63,18 @@ func kvparse(p *ju.JobKv, e *ExtractTask, sonJobResult *map[string]interface{},
 					if data[0] ==0{
 						if istrue,ok:= data[len(data)-1].(bool);istrue&&ok{
 							(*sonJobResult)["budget"] = data[0]
-						}else {
-							continue
 						}
 					}
-					(*sonJobResult)["budget"] = data[0]
 					continue
 				}
 				if qu.Float64All((*sonJobResult)["bidamount"]) == 0 && tags[0].Key == "中标金额" {
 					lock.Lock()
-					cfn := e.ClearFn["budget"]
+					cfn := e.ClearFn["bidamount"]
 					lock.Unlock()
 					data := clear.DoClearFn(cfn, []interface{}{pv[0].Value, ""})
 					if istrue,ok:= data[len(data)-1].(bool);istrue&&ok{
-						(*sonJobResult)["budget"] = data[0]
-					}else {
-						continue
+						(*sonJobResult)["bidamount"] = data[0]
 					}
-					(*sonJobResult)["bidamount"] = data[0]
 					continue
 				}
 				if ((*sonJobResult)["winner"] == nil || (*sonJobResult)["winner"] == "") && tags[0].Key == "中标单位" {

+ 81 - 42
src/jy/extract/extract.go

@@ -584,11 +584,11 @@ func (e *ExtractTask) ExtractDetail(j *ju.Job, isSite bool, codeSite string) {
 				}
 				data := clear.DoClearFn(cfn, []interface{}{v.Value, j.Content})
 				if key == "budget" || key == "bidamount" {
-						if istrue, ok := data[len(data)-1].(bool); istrue && ok {
-							j.Result[key][i].IsTrue = true
-						} else {
-							continue
-						}
+					if istrue, ok := data[len(data)-1].(bool); istrue && ok {
+						j.Result[key][i].IsTrue = true
+					} else {
+						continue
+					}
 				}
 				before, _ := v.Value.(string)
 				v.Value = data[0]
@@ -797,7 +797,10 @@ func ExtRuleCore(doc map[string]interface{}, e *ExtractTask, vc *RuleCore, j *ju
 				j.Result[k] = [](*ju.ExtField){}
 			}
 			for _, tmp := range v {
-				field := &ju.ExtField{Weight: qu.IntAll(tmp["weight"]), Field: k, Code: qu.ObjToString(tmp["code"]), Type: qu.ObjToString(tmp["type"]), MatchType: qu.ObjToString(tmp["matchtype"]), RuleText: qu.ObjToString(tmp["ruletext"]), SourceValue: tmp["sourcevalue"], Value: tmp["value"]}
+				field := &ju.ExtField{Weight: qu.IntAll(tmp["weight"]), ExtFrom: qu.ObjToString(tmp["extfrom"]), Field: k, Code: qu.ObjToString(tmp["code"]), Type: qu.ObjToString(tmp["type"]), MatchType: qu.ObjToString(tmp["matchtype"]), RuleText: qu.ObjToString(tmp["ruletext"]), SourceValue: tmp["sourcevalue"], Value: tmp["value"]}
+				if k == "bidamount" && field.ExtFrom == "第一候选人" {
+					field.Score = 1
+				}
 				if isSite {
 					field.Score = 1
 				}
@@ -1038,12 +1041,15 @@ func getKvByLuaFields(vc *RuleCore, j *ju.Job, et *ExtractTask) (map[string][]ma
 	if len(j.Winnerorder) > 1 {
 		if vc.Field == "bidamount" {
 			for _, v := range j.Winnerorder {
+				if v["price"] == nil {
+					continue
+				}
 				kvmap[vc.Field] = append(kvmap[vc.Field], map[string]interface{}{
 					"code":        "winnerorder",
 					"field":       vc.Field,
 					"ruletext":    "中标候选人",
-					"extfrom":     vc.ExtFrom,
-					"sourcevalue": "中标候选人",
+					"extfrom":     v["sortstr"],
+					"sourcevalue": v["price"],
 					"value":       v["price"],
 					"type":        "winnerorder",
 					"matchtype":   "winnerorder",
@@ -1055,8 +1061,8 @@ func getKvByLuaFields(vc *RuleCore, j *ju.Job, et *ExtractTask) (map[string][]ma
 					"code":        "CL_中标候选人",
 					"field":       vc.Field,
 					"ruletext":    "中标候选人",
-					"extfrom":     vc.ExtFrom,
-					"sourcevalue": "中标候选人",
+					"extfrom":     j.Winnerorder[0]["sortstr"],
+					"sourcevalue": price,
 					"value":       price,
 					"type":        "winnerorder",
 					"matchtype":   "winnerorder",
@@ -1576,22 +1582,38 @@ func AnalysisSaveResult(j, jf *ju.Job, e *ExtractTask) {
 		tmp["fieldall"] = auxinfo
 		for _, val := range result {
 			for _, v := range val { //取第一个非负数,项目名称除外
+				//存0是否有效
+				if v.Field == "bidamount" || v.Field == "budget" && v.IsTrue {
+					tmp[v.Field] = v.Value
+					break
+				}
 				if v.Score > -1 {
 					tmp[v.Field] = v.Value
 					break
 				} else if v.Field == "projectname" {
 					tmp[v.Field] = v.Value
 					break
-				} else if v.Field == "bidamount"||v.Field =="budget"{
-					if v.IsTrue{
-						tmp[v.Field] =v.Value
-						break
-					}
 				}
 			}
 		}
 		if len(j.PackageInfo) > 0 { //分包信息
 			tmp["package"] = j.PackageInfo
+			var tmpBidamount, tmpBudget float64
+			//包预算,中标金额合并大于抽取就覆盖
+			for _, v := range j.PackageInfo {
+				if v["budget"] != nil {
+					tmpBudget += qu.Float64All(v["budget"])
+				}
+				if v["bidamount"] != nil {
+					tmpBidamount += qu.Float64All(v["bidamount"])
+				}
+			}
+			if qu.Float64All(tmp["budget"]) < tmpBudget {
+				tmp["budget"] = tmpBudget
+			}
+			if qu.Float64All(tmp["bidamount"]) < tmpBidamount {
+				tmp["bidamount"] = tmpBidamount
+			}
 		}
 		if len(j.Winnerorder) > 0 { //候选人信息
 			tmp["winnerorder"] = j.Winnerorder
@@ -1888,8 +1910,8 @@ func auxInfo(j *ju.Job) map[string][]map[string]interface{} {
 					standardized = true
 				}
 			}
-			if field == "budget"||field == "bidamount"{
-				if !v.IsTrue{
+			if field == "budget" || field == "bidamount" {
+				if !v.IsTrue {
 					continue
 				}
 			}
@@ -2020,34 +2042,51 @@ func resetWinnerorder(j *ju.Job) {
 	}
 	maxlen := len(j.Winnerorder) - 1
 	//中标单位
-	i := 0
+	//i := 0
 	winners := []*ju.ExtField{}
-	for _, v := range j.Result["winner"] {
-		if v.Code == "winnerorder" {
-			if maxlen < i {
-				continue
-			}
-			j.Winnerorder[i]["entname"] = v.Value
-			i++
-		} else {
-			winners = append(winners, v)
-		}
-	}
-	j.Result["winner"] = winners
-	//中标金额
-	i = 0
 	bidamounts := []*ju.ExtField{}
-	for _, v := range j.Result["bidamount"] {
-		if v.Code == "winnerorder" {
-			if maxlen < i {
-				continue
-			}
-			j.Winnerorder[i]["price"] = v.Value
-			i++
-		} else {
-			bidamounts = append(bidamounts, v)
+	//for _, v := range j.Result["winner"] {
+	//	if v.Code == "winnerorder" {
+	//		if maxlen < i {
+	//			continue
+	//		}
+	//		j.Winnerorder[i]["entname"] = v.Value
+	//		i++
+	//	} else {
+	//		winners = append(winners, v)
+	//	}
+	//}
+	if maxlen > 0 {
+		winners = append(winners, &ju.ExtField{Code: "winnerorder", Field: "winner", ExtFrom: "j.Winnerorder", Value: j.Winnerorder[0]["entname"], Score: 0.5})
+		if j.Winnerorder[0]["price"] != nil {
+			bidamounts = append(bidamounts, &ju.ExtField{Code: "winnerorder", Field: "bidamount", ExtFrom: "j.Winnerorder", Value: j.Winnerorder[0]["price"], Score: 0.5})
 		}
 	}
-	j.Result["bidamount"] = bidamounts
+	if j.Result["winner"] == nil && len(winners) > 0 {
+		j.Result["winner"] = winners
+	} else {
+		j.Result["winner"] = append(j.Result["winner"], winners...)
+	}
+	if j.Result["bidamount"] == nil && len(bidamounts) > 0 {
+		j.Result["bidamount"] = bidamounts
+	} else {
+		j.Result["bidamount"] = append(j.Result["bidamount"], bidamounts...)
+	}
+	//j.Result["winner"] = winners
+	//中标金额
+	//i = 0
+	//bidamounts := []*ju.ExtField{}
+	//for _, v := range j.Result["bidamount"] {
+	//	if v.Code == "winnerorder" {
+	//		if maxlen < i {
+	//			continue
+	//		}
+	//		j.Winnerorder[i]["price"] = v.Value
+	//		i++
+	//	} else {
+	//		bidamounts = append(bidamounts, v)
+	//	}
+	//}
+	//j.Result["bidamount"] = bidamounts
 
 }

+ 9 - 0
src/jy/extract/score.go

@@ -104,6 +104,7 @@ func init() {
 	}
 }
 
+var CNreg = regexp.MustCompile("[\u4e00-\u9fa5]")
 //结果打分
 func ScoreFields(j *ju.Job, ftag map[string][]*Tag) map[string][]*ju.ExtField {
 	qu.Catch()
@@ -112,6 +113,14 @@ func ScoreFields(j *ju.Job, ftag map[string][]*Tag) map[string][]*ju.ExtField {
 		if field == "projectcode" {
 			tmps = projectWeightClear(tmps)
 		}
+		if field == "budget" || field == "bidamount" {
+			for tmpsindex, tmpsvalue := range tmps {
+				if strings.Contains(tmpsvalue.RuleText,"总") && tmpsvalue.Type =="colon"{
+					tmps[tmpsindex].Score += 1
+					tmps[tmpsindex].ScoreItem = append(tmps[tmpsindex].ScoreItem, &ju.ScoreItem{Des: field+`value结果含总字+1`, Code: field, Value: tmpsvalue.Value, Score:1})
+				}
+			}
+		}
 		locktag.Lock()
 		taglength := len(ftag[field])
 		locktag.Unlock()

+ 19 - 6
src/jy/extract/score_jsondata.go

@@ -29,10 +29,10 @@ func JsonDataMergeProcessing(j *util.Job, e *ExtractTask) map[string][]*util.Ext
 				lockclear.Lock()
 				cfn := e.ClearFn[v]
 				lockclear.Unlock()
-				newNum := clear.DoClearFn(cfn, []interface{}{util2.Float64All((*j.Jsondata)[v]), ""})
+				newNum := clear.DoClearFn(cfn, []interface{}{(*j.Jsondata)[v], ""})
 				if util2.IntAll(newNum[0]) != 0 {
 					extFields := make([]*util.ExtField, 0)
-					extFields = append(extFields, &util.ExtField{Code: "JsonData_" + v + "_" + fmt.Sprint(jdextweight), Field: v, ExtFrom: "JsonData_" + v + "_" + fmt.Sprint(jdextweight), SourceValue: (*j.Jsondata)[v], Value: newNum[0], Score: 0.1})
+					extFields = append(extFields, &util.ExtField{Code: "JsonData_" + v + "_" + fmt.Sprint(jdextweight), Field: v, ExtFrom: "JsonData_" + v + "_" + fmt.Sprint(jdextweight), SourceValue: (*j.Jsondata)[v], Value: newNum[0], Score: 0.1,IsTrue:newNum[len(newNum)-1].(bool)})
 					j.Result[v] = extFields
 					//AddExtLog("extract", j.SourceMid, nil, newNum[0], &RegLuaInfo{ "JsonData_"+v, "", v, "", false, nil, nil}, e.TaskInfo) //抽取日志
 					//AddExtLog("clear", j.SourceMid, (*j.Jsondata)[v], newNum[0], &RegLuaInfo{ "JsonData_"+v, "", v, "", false, nil, nil}, e.TaskInfo) //抽取日志
@@ -120,15 +120,26 @@ func JsonDataMergeProcessing(j *util.Job, e *ExtractTask) map[string][]*util.Ext
 			if jdextweight == 0 {
 				continue
 			}
+			oneScore := j.Result[v][0].Score
 			if v == "budget" || v == "bidamount" {
 				lockclear.Lock()
 				cfn := e.ClearFn[v]
 				lockclear.Unlock()
-				newNum := clear.DoClearFn(cfn, []interface{}{util2.Float64All((*j.Jsondata)[v]), ""})
+				newNum := clear.DoClearFn(cfn, []interface{}{(*j.Jsondata)[v], ""})
 				if util2.IntAll(newNum[0]) != 0 {
 					extFields := make([]*util.ExtField, 0)
-					extFields = append(extFields, &util.ExtField{Code: "JsonData_" + v + "_" + fmt.Sprint(jdextweight), Field: v, ExtFrom: "JsonData_" + v + "_" + fmt.Sprint(jdextweight), SourceValue: (*j.Jsondata)[v], Value: newNum[0], Score: 0.1})
-					j.Result[v] = extFields
+					if jdextweight >1{
+						if oneScore < 0{
+							oneScore =0.1
+						}
+						extFields = append(extFields, &util.ExtField{Code: "JsonData_" + v + "_" + fmt.Sprint(jdextweight), Field: v, ExtFrom: "JsonData_" + v + "_" + fmt.Sprint(jdextweight), SourceValue: (*j.Jsondata)[v], Value: newNum[0], Score: oneScore+1,IsTrue:newNum[len(newNum)-1].(bool)})
+					}else {
+						if oneScore < 0{
+							oneScore =0.1
+						}
+						extFields = append(extFields, &util.ExtField{Code: "JsonData_" + v + "_" + fmt.Sprint(jdextweight), Field: v, ExtFrom: "JsonData_" + v + "_" + fmt.Sprint(jdextweight), SourceValue: (*j.Jsondata)[v], Value: newNum[0], Score: oneScore,IsTrue:newNum[len(newNum)-1].(bool)})
+					}
+					j.Result[v] = append(j.Result[v], extFields...)
 					//AddExtLog("extract", j.SourceMid, nil, newNum[0], &RegLuaInfo{ "JsonData_"+v, "", v, "", false, nil, nil}, e.TaskInfo) //抽取日志
 					//AddExtLog("clear", j.SourceMid, (*j.Jsondata)[v], newNum[0], &RegLuaInfo{ "JsonData_"+v, "", v, "", false, nil, nil}, e.TaskInfo) //抽取日志
 				}
@@ -137,7 +148,6 @@ func JsonDataMergeProcessing(j *util.Job, e *ExtractTask) map[string][]*util.Ext
 
 			if strings.Trim(util2.ObjToString(j.Result[v][0].Value), " ") != strings.Trim(util2.ObjToString((*j.Jsondata)[v]), " ") {
 				tmp = append(tmp, j.Result[v][0])
-				oneScore := j.Result[v][0].Score
 				if jdextweight == 2 {
 					oneScore += 2
 				}
@@ -176,6 +186,7 @@ func JsonDataMergeProcessing(j *util.Job, e *ExtractTask) map[string][]*util.Ext
 									score := util2.Float64All(ranges[2])
 									if valueLen > gt && valueLen <= lte {
 										v[i].Score += score
+										v[i].ScoreItem = append(v[i].ScoreItem, &util.ScoreItem{Des: "JsonData长度打分", Code: fmt.Sprint(gt, "<", valueLen, "<=", lte), ScoreFrom: "fieldscore.json.length", Value: tmpsvalue.Value, Score: score})
 										break
 									}
 								}
@@ -191,6 +202,7 @@ func JsonDataMergeProcessing(j *util.Job, e *ExtractTask) map[string][]*util.Ext
 										reg := p["regexp"].(*regexp.Regexp)
 										if reg.MatchString(util2.ObjToString(tmpsvalue.Value)) {
 											v[i].Score += util2.Float64All(p["score"])
+											v[i].ScoreItem = append(v[i].ScoreItem, &util.ScoreItem{Des: "JsonData负面词打分" + fmt.Sprint(p["describe"]), Code: "negativewords", RuleText: reg.String(), ScoreFrom: "fieldscore.json.negativewords", Value: tmpsvalue.Value, Score: util2.Float64All(p["score"])})
 										}
 									}
 								}, func(err interface{}) {
@@ -208,6 +220,7 @@ func JsonDataMergeProcessing(j *util.Job, e *ExtractTask) map[string][]*util.Ext
 										reg := p["regexp"].(*regexp.Regexp)
 										if reg.MatchString(util2.ObjToString(tmpsvalue.Value)) {
 											v[i].Score += util2.Float64All(p["score"])
+											v[i].ScoreItem = append(v[i].ScoreItem, &util.ScoreItem{Des: "Jsondata正面词打分" + fmt.Sprint(p["describe"]), Code: "positivewords", RuleText: reg.String(), ScoreFrom: "fieldscore.json.positivewords", Value: tmpsvalue.Value, Score: util2.Float64All(p["score"])})
 										}
 									}
 								}, func(err interface{}) {

+ 14 - 6
src/jy/pretreated/spacekv.go

@@ -16,18 +16,18 @@ var (
 	excludeSpaceKey = regexp.MustCompile("[.、�\\[【{{〔<《\\]】}}〕>》]")
 )
 
-func (se *SpacekvEntity) Entrance(text, title string, contactFormat *util.ContactFormat,isSite bool,codeSite string) *util.JobKv {
+func (se *SpacekvEntity) Entrance(text, title string, contactFormat *util.ContactFormat, isSite bool, codeSite string) *util.JobKv {
 	lines := se.getLines(text)
 	kvMaps := []*util.Kv{}
 	for _, line := range lines {
-		kvMap := se.divideKV(line,isSite,codeSite)
+		kvMap := se.divideKV(line, isSite, codeSite)
 		if kvMap == nil {
 			continue
 		}
 		kvMaps = append(kvMaps, kvMap...)
 	}
-	FormatContactKv(&kvMaps, title, nil, contactFormat,isSite,codeSite)
-	kvTags := GetKvTags(kvMaps, title, nil,isSite,codeSite)
+	FormatContactKv(&kvMaps, title, nil, contactFormat, isSite, codeSite)
+	kvTags := GetKvTags(kvMaps, title, nil, isSite, codeSite)
 	return &util.JobKv{
 		Kvs:    kvMaps,
 		KvTags: kvTags,
@@ -35,7 +35,7 @@ func (se *SpacekvEntity) Entrance(text, title string, contactFormat *util.Contac
 }
 
 //空格分kv
-func (se *SpacekvEntity) divideKV(line string,isSite bool,codeSite string) []*util.Kv {
+func (se *SpacekvEntity) divideKV(line string, isSite bool, codeSite string) []*util.Kv {
 	line = strings.TrimSpace(line)
 	line = regReplAllSpace.ReplaceAllString(line, " ")
 	line = TimeHM.ReplaceAllString(line, "D$1H$2M")
@@ -55,8 +55,16 @@ func (se *SpacekvEntity) divideKV(line string,isSite bool,codeSite string) []*ut
 		if excludeSpaceKey.MatchString(k) {
 			continue
 		}
+		ktags := util.GetTags(k, isSite, codeSite)
 		//value为key值跳过
-		if util.GetTags(v,isSite,codeSite).Len() > 0 && util.GetTags(k,isSite,codeSite).Len() > 0{
+		if util.GetTags(v, isSite, codeSite).Len() > 0 && ktags.Len() > 0 {
+			continue
+		}
+		if ktags.Len() > 0 && (ktags[0].Value == "中标金额" || ktags[0].Value == "预算") && strings.Contains(kv[i], "万") {
+			kvs = append(kvs, &util.Kv{Key: k, Value: v + "万"})
+			continue
+		} else if ktags.Len() > 0 && (ktags[0].Value == "中标金额" || ktags[0].Value == "预算") && strings.Contains(kv[i], "亿") {
+			kvs = append(kvs, &util.Kv{Key: k, Value: v + "亿"})
 			continue
 		}
 		kvs = append(kvs, &util.Kv{Key: k, Value: v})

+ 7 - 0
src/res/fieldscore.json

@@ -40,6 +40,13 @@
                 "space": 3,
                 "regexp": 2,
                 "kvweight": 5
+            },
+            "bidamount": {
+                "table": 3,
+                "colon": 2,
+                "space": 2,
+                "regexp": 2,
+                "kvweight": 1
             }
         }
     },