|
@@ -5,32 +5,43 @@ import (
|
|
log "github.com/donnie4w/go-logger/logger"
|
|
log "github.com/donnie4w/go-logger/logger"
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
qu "qfw/util"
|
|
qu "qfw/util"
|
|
|
|
+ "regexp"
|
|
"strings"
|
|
"strings"
|
|
"sync"
|
|
"sync"
|
|
"unicode/utf8"
|
|
"unicode/utf8"
|
|
ul "util"
|
|
ul "util"
|
|
)
|
|
)
|
|
|
|
|
|
-var fields = map[string]interface{}{"toptype": 1, "subtype": 1, "subscopeclass": 1, "extracttype": 1, "purchasinglist": 1}
|
|
|
|
-
|
|
|
|
|
|
+var BidFields = map[string]interface{}{"toptype": 1, "subtype": 1, "s_topscopeclass": 1, "s_subscopeclass": 1, "buyerclass": 1, "buyer": 1, "extracttype": 1, "purchasinglist": 1}
|
|
var datalock, numlock sync.Mutex
|
|
var datalock, numlock sync.Mutex
|
|
|
|
|
|
-func RunPurchasingInfo(gtid string, lteid string) {
|
|
|
|
- log.Debug("开始处理标讯信息~~~", gtid, "~", lteid)
|
|
|
|
|
|
+var A_FieldReg *regexp.Regexp = regexp.MustCompile("(医疗卫生_设备|医疗卫生_耗材)")
|
|
|
|
+var B_FieldReg *regexp.Regexp = regexp.MustCompile("^(医疗|卫健委)$")
|
|
|
|
+
|
|
|
|
+func RunPurchasingInfo(gtid string, lteid string, obj_id bool) {
|
|
|
|
+ log.Debug("开始处理标讯信息~~~", ul.S_Bidding_Coll, "~", gtid, "~", lteid)
|
|
sess := ul.Mgo.GetMgoConn()
|
|
sess := ul.Mgo.GetMgoConn()
|
|
defer ul.Mgo.DestoryMongoConn(sess)
|
|
defer ul.Mgo.DestoryMongoConn(sess)
|
|
q := map[string]interface{}{
|
|
q := map[string]interface{}{
|
|
"_id": map[string]interface{}{
|
|
"_id": map[string]interface{}{
|
|
- "$gt": class.StringTOBsonId(gtid),
|
|
|
|
- "$lte": class.StringTOBsonId(lteid),
|
|
|
|
|
|
+ "$gt": gtid,
|
|
|
|
+ "$lte": lteid,
|
|
},
|
|
},
|
|
}
|
|
}
|
|
- it := sess.DB(ul.Mgo.DbName).C(ul.S_Bidding_Coll).Find(&q).Sort("_id").Select(fields).Iter()
|
|
|
|
|
|
+ if obj_id {
|
|
|
|
+ q = map[string]interface{}{
|
|
|
|
+ "_id": map[string]interface{}{
|
|
|
|
+ "$gt": class.StringTOBsonId(gtid),
|
|
|
|
+ "$lte": class.StringTOBsonId(lteid),
|
|
|
|
+ },
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ it := sess.DB(ul.Mgo.DbName).C(ul.S_Bidding_Coll).Find(&q).Sort("_id").Select(BidFields).Iter()
|
|
pool := make(chan bool, 8)
|
|
pool := make(chan bool, 8)
|
|
wg := &sync.WaitGroup{}
|
|
wg := &sync.WaitGroup{}
|
|
total, isok := 0, 0
|
|
total, isok := 0, 0
|
|
for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
|
|
for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
|
|
- if total%100 == 0 {
|
|
|
|
|
|
+ if total%1000 == 0 {
|
|
log.Debug("cur index ", total, "~", isok)
|
|
log.Debug("cur index ", total, "~", isok)
|
|
}
|
|
}
|
|
if qu.IntAll(tmp["extracttype"]) != 1 {
|
|
if qu.IntAll(tmp["extracttype"]) != 1 {
|
|
@@ -44,11 +55,21 @@ func RunPurchasingInfo(gtid string, lteid string) {
|
|
<-pool
|
|
<-pool
|
|
wg.Done()
|
|
wg.Done()
|
|
}()
|
|
}()
|
|
- //构建标的物基本信息
|
|
|
|
- b := createBaseInfo(tmp)
|
|
|
|
|
|
+ infoid := ""
|
|
|
|
+ if obj_id {
|
|
|
|
+ infoid = class.BsonTOStringId(tmp["_id"])
|
|
|
|
+ } else {
|
|
|
|
+ infoid = qu.ObjToString(tmp["_id"])
|
|
|
|
+ }
|
|
|
|
+ b := createBaseInfo(tmp, infoid) //构建信息
|
|
if b {
|
|
if b {
|
|
numlock.Lock()
|
|
numlock.Lock()
|
|
isok++
|
|
isok++
|
|
|
|
+ ul.Mgo.UpdateById(ul.U_Bidding_Coll, class.BsonTOStringId(tmp["_id"]), map[string]interface{}{
|
|
|
|
+ "$set": map[string]interface{}{
|
|
|
|
+ "bid_field": "0101",
|
|
|
|
+ },
|
|
|
|
+ })
|
|
numlock.Unlock()
|
|
numlock.Unlock()
|
|
}
|
|
}
|
|
}(tmp)
|
|
}(tmp)
|
|
@@ -59,55 +80,61 @@ func RunPurchasingInfo(gtid string, lteid string) {
|
|
log.Debug("is over ", total, "~", isok)
|
|
log.Debug("is over ", total, "~", isok)
|
|
}
|
|
}
|
|
|
|
|
|
-//构建标的物基本信息
|
|
|
|
-func createBaseInfo(tmp map[string]interface{}) bool {
|
|
|
|
|
|
+//构建标的物基本信息~模式一~规则型
|
|
|
|
+func createBaseInfo(tmp map[string]interface{}, infoid string) bool {
|
|
p_list := IsMarkInterfaceMap(tmp["purchasinglist"])
|
|
p_list := IsMarkInterfaceMap(tmp["purchasinglist"])
|
|
- sub_list := IsMarkInterfaceArr(tmp["subscopeclass"])
|
|
|
|
- infoid := class.BsonTOStringId(tmp["_id"])
|
|
|
|
|
|
+ new_plist := []map[string]interface{}{}
|
|
bid_topsubtype_code := confrimTopSubCode(qu.ObjToString(tmp["toptype"]), qu.ObjToString(tmp["subtype"]))
|
|
bid_topsubtype_code := confrimTopSubCode(qu.ObjToString(tmp["toptype"]), qu.ObjToString(tmp["subtype"]))
|
|
- b, industry_code, new_plist := checkWhetherValidInfo(p_list, sub_list)
|
|
|
|
- if b {
|
|
|
|
|
|
+ industry_code := confrimIndustryCode(qu.ObjToString(tmp["s_topscopeclass"]), qu.ObjToString(tmp["s_subscopeclass"]))
|
|
|
|
+ isField := IsMedicalFieldInfoRuleFirst(tmp)
|
|
|
|
+ if isField {
|
|
|
|
+ _, new_plist = createNewPurchasingInfo(p_list, infoid)
|
|
|
|
+ } else {
|
|
|
|
+ if IsMedicalFieldInfoRuleSecond(tmp) {
|
|
|
|
+ isField, new_plist = createNewPurchasingInfo(p_list, infoid)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if isField { //最终根据是否为领域数据灌入数据
|
|
//标的物基本信息~记录标签
|
|
//标的物基本信息~记录标签
|
|
- //insertBaseInfo(new_plist, infoid, bid_topsubtype_code)
|
|
|
|
|
|
+ insertBaseInfo(new_plist, infoid, bid_topsubtype_code)
|
|
//招标信息领域标签
|
|
//招标信息领域标签
|
|
- //insertFiledTag(infoid)
|
|
|
|
|
|
+ insertFiledTag(infoid)
|
|
//招标信息行业标签
|
|
//招标信息行业标签
|
|
- //insertIndustryTag(industry_code, infoid)
|
|
|
|
|
|
+ insertIndustryTag(industry_code, infoid)
|
|
}
|
|
}
|
|
- if industry_code != "" && len(new_plist) > 0 && bid_topsubtype_code != "" && infoid != "" {
|
|
|
|
|
|
|
|
- }
|
|
|
|
- return b
|
|
|
|
-}
|
|
|
|
|
|
+ //临时处理
|
|
|
|
+ //isField, new_plist := createNewPurchasingInfo(p_list, infoid)
|
|
|
|
+ //if isField { //最终根据是否为领域数据灌入数据
|
|
|
|
+ // //标的物基本信息~记录标签
|
|
|
|
+ // insertBaseInfo(new_plist, infoid, bid_topsubtype_code)
|
|
|
|
+ // //招标信息领域标签
|
|
|
|
+ // insertFiledTag(infoid)
|
|
|
|
+ // //招标信息行业标签
|
|
|
|
+ // insertIndustryTag(industry_code, infoid)
|
|
|
|
+ //}
|
|
|
|
|
|
-//return 是否有效~行业代码~新标的物信息
|
|
|
|
-func checkWhetherValidInfo(p_list []map[string]interface{}, sub_list []string) (bool, string, []map[string]interface{}) {
|
|
|
|
- is_exists := false
|
|
|
|
- industry_code, b := IsIndustryInfo(sub_list)
|
|
|
|
- new_plist := []map[string]interface{}{}
|
|
|
|
- if len(p_list) > 0 && b {
|
|
|
|
- is_exists, new_plist = createNewPurchasingInfo(p_list)
|
|
|
|
- }
|
|
|
|
- return is_exists, industry_code, new_plist
|
|
|
|
|
|
+ //阻止注释~报错
|
|
|
|
+ //if bid_topsubtype_code == "" || industry_code == "" || len(new_plist) == 0 {}
|
|
|
|
+
|
|
|
|
+ return isField
|
|
}
|
|
}
|
|
|
|
|
|
//返回新的~标的物信息(分类+整合)
|
|
//返回新的~标的物信息(分类+整合)
|
|
-func createNewPurchasingInfo(p_list []map[string]interface{}) (bool, []map[string]interface{}) {
|
|
|
|
- is_exists := false
|
|
|
|
|
|
+func createNewPurchasingInfo(p_list []map[string]interface{}, infoid string) (bool, []map[string]interface{}) {
|
|
new_plist := []map[string]interface{}{}
|
|
new_plist := []map[string]interface{}{}
|
|
|
|
+ isExists := false
|
|
for _, v := range p_list {
|
|
for _, v := range p_list {
|
|
//去重处理~名称~品牌~型号~暂无重复
|
|
//去重处理~名称~品牌~型号~暂无重复
|
|
-
|
|
|
|
data := map[string]interface{}{}
|
|
data := map[string]interface{}{}
|
|
itemname := qu.ObjToString(v["itemname"])
|
|
itemname := qu.ObjToString(v["itemname"])
|
|
- if itemname == "" {
|
|
|
|
|
|
+ if itemname == "" || utf8.RuneCountInString(itemname) > 30 {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
//根据标的物名字~打上具体的分类数据~
|
|
//根据标的物名字~打上具体的分类数据~
|
|
- is_yl, yl_code := confrimYlClassCode(itemname)
|
|
|
|
-
|
|
|
|
- if !is_exists && is_yl {
|
|
|
|
- is_exists = true //证明此条信息有效果
|
|
|
|
|
|
+ yl_code := confrimTargetMedicalClass(itemname, infoid)
|
|
|
|
+ if yl_code != "" {
|
|
|
|
+ isExists = true
|
|
}
|
|
}
|
|
data["medical_equipment_code"] = yl_code
|
|
data["medical_equipment_code"] = yl_code
|
|
data["itemname"] = itemname
|
|
data["itemname"] = itemname
|
|
@@ -118,7 +145,6 @@ func createNewPurchasingInfo(p_list []map[string]interface{}) (bool, []map[strin
|
|
}
|
|
}
|
|
data["model"] = model
|
|
data["model"] = model
|
|
data["specs"] = qu.ObjToString(v["specs"])
|
|
data["specs"] = qu.ObjToString(v["specs"])
|
|
-
|
|
|
|
if v["unitname"] != nil {
|
|
if v["unitname"] != nil {
|
|
data["unit"] = qu.ObjToString(v["unitname"])
|
|
data["unit"] = qu.ObjToString(v["unitname"])
|
|
}
|
|
}
|
|
@@ -140,37 +166,88 @@ func createNewPurchasingInfo(p_list []map[string]interface{}) (bool, []map[strin
|
|
}
|
|
}
|
|
new_plist = append(new_plist, data)
|
|
new_plist = append(new_plist, data)
|
|
}
|
|
}
|
|
- return is_exists, new_plist
|
|
|
|
|
|
+ return isExists, new_plist
|
|
}
|
|
}
|
|
|
|
|
|
//是否为医疗行业数据
|
|
//是否为医疗行业数据
|
|
-func IsIndustryInfo(sub_list []string) (string, bool) {
|
|
|
|
|
|
+func IsMedicalFieldInfoRuleFirst(tmp map[string]interface{}) bool {
|
|
|
|
+ top_class := qu.ObjToString(tmp["s_topscopeclass"])
|
|
|
|
+ sub_class := qu.ObjToString(tmp["s_subscopeclass"])
|
|
|
|
+ buyer_class := qu.ObjToString(tmp["buyerclass"])
|
|
|
|
+ buyer := qu.ObjToString(tmp["buyer"])
|
|
|
|
+ if isFieldInfoMethodFirst(top_class, sub_class, buyer_class, buyer) {
|
|
|
|
+ return true
|
|
|
|
+ }
|
|
|
|
+ return false
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//是否为医疗行业数据
|
|
|
|
+func IsMedicalFieldInfoRuleSecond(tmp map[string]interface{}) bool {
|
|
|
|
+ top_class := qu.ObjToString(tmp["s_topscopeclass"])
|
|
|
|
+ sub_class := qu.ObjToString(tmp["s_subscopeclass"])
|
|
|
|
+ buyer_class := qu.ObjToString(tmp["buyerclass"])
|
|
|
|
+ buyer := qu.ObjToString(tmp["buyer"])
|
|
|
|
+ if isFieldInfoMethodSecond(top_class, sub_class, buyer_class, buyer) {
|
|
|
|
+ return true
|
|
|
|
+ }
|
|
|
|
+ return false
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//第一组规则条件是否校验通过
|
|
|
|
+func isFieldInfoMethodFirst(top_class string, sub_class string, buyer_class string, buyer string) bool {
|
|
|
|
+ is_A, is_B := false, false
|
|
|
|
+ if A_FieldReg.MatchString(sub_class) || (sub_class == "" && strings.Contains(top_class, "医疗卫生")) {
|
|
|
|
+ is_A = true
|
|
|
|
+ }
|
|
|
|
+ if !is_A {
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ if B_FieldReg.MatchString(buyer_class) || (buyer_class == "制造业" && strings.Contains(buyer, "医疗器械") && strings.Contains(buyer, "公司")) {
|
|
|
|
+ is_B = true
|
|
|
|
+ }
|
|
|
|
+ return is_A && is_B
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//第二组规则条件是否校验通过
|
|
|
|
+func isFieldInfoMethodSecond(top_class string, sub_class string, buyer_class string, buyer string) bool {
|
|
|
|
+ is_A, is_B := false, false
|
|
|
|
+ if A_FieldReg.MatchString(sub_class) || (sub_class == "" && strings.Contains(top_class, "医疗卫生")) {
|
|
|
|
+ is_A = true
|
|
|
|
+ }
|
|
|
|
+ if !is_A {
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ if !(B_FieldReg.MatchString(buyer_class) || (buyer_class == "制造业" && strings.Contains(buyer, "医疗器械") && strings.Contains(buyer, "公司"))) {
|
|
|
|
+ is_B = true
|
|
|
|
+ }
|
|
|
|
+ return is_A && is_B
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//确认行业code
|
|
|
|
+func confrimIndustryCode(top_class string, sub_class string) string {
|
|
code := ""
|
|
code := ""
|
|
- b := false
|
|
|
|
- for _, v := range sub_list {
|
|
|
|
|
|
+ top_arr := strings.Split(top_class, ",")
|
|
|
|
+ for _, v := range top_arr {
|
|
|
|
+ vc := ul.Bid_Industry[v]["code"]
|
|
|
|
+ if code != "" {
|
|
|
|
+ code += ","
|
|
|
|
+ }
|
|
|
|
+ code += vc
|
|
|
|
+ }
|
|
|
|
+ sub_arr := strings.Split(sub_class, ",")
|
|
|
|
+ for _, v := range sub_arr {
|
|
arr := strings.Split(v, "_")
|
|
arr := strings.Split(v, "_")
|
|
if len(arr) == 2 {
|
|
if len(arr) == 2 {
|
|
industry_1 := arr[0]
|
|
industry_1 := arr[0]
|
|
industry_2 := arr[1]
|
|
industry_2 := arr[1]
|
|
- if industry_1 == "医疗卫生" && (industry_2 == "设备" || industry_2 == "耗材") {
|
|
|
|
- b = true
|
|
|
|
- code = ul.Bid_Industry[industry_1][industry_2]
|
|
|
|
- break
|
|
|
|
|
|
+ vc := ul.Bid_Industry[industry_1][industry_2]
|
|
|
|
+ if code != "" {
|
|
|
|
+ code += ","
|
|
}
|
|
}
|
|
|
|
+ code += vc
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return code, b
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-//根据标的物名称~打医疗分类
|
|
|
|
-func confrimYlClassCode(name string) (bool, string) {
|
|
|
|
- is_b := false
|
|
|
|
- yl_code := ""
|
|
|
|
- yl_code = ConfrimTargetMedicalClass(name)
|
|
|
|
- if utf8.RuneCountInString(yl_code) > 0 {
|
|
|
|
- is_b = true
|
|
|
|
- }
|
|
|
|
- return is_b, yl_code
|
|
|
|
|
|
+ return code
|
|
}
|
|
}
|
|
|
|
|
|
//根据标的物名称~打医疗分类
|
|
//根据标的物名称~打医疗分类
|