|
@@ -12,23 +12,31 @@ import (
|
|
|
ul "util"
|
|
|
)
|
|
|
|
|
|
-var fields = map[string]interface{}{"toptype": 1, "subtype": 1, "s_topscopeclass": 1, "s_subscopeclass": 1, "buyerclass": 1, "buyer": 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 A_FieldReg *regexp.Regexp = regexp.MustCompile("(医疗卫生_设备|医疗卫生_耗材)")
|
|
|
var B_FieldReg *regexp.Regexp = regexp.MustCompile("^(医疗|卫健委)$")
|
|
|
|
|
|
-func RunPurchasingInfo(gtid string, lteid string) {
|
|
|
- log.Debug("开始处理标讯信息~~~", gtid, "~", lteid)
|
|
|
+func RunPurchasingInfo(gtid string, lteid string, obj_id bool) {
|
|
|
+ log.Debug("开始处理标讯信息~~~", ul.S_Bidding_Coll, "~", gtid, "~", lteid)
|
|
|
sess := ul.Mgo.GetMgoConn()
|
|
|
defer ul.Mgo.DestoryMongoConn(sess)
|
|
|
q := 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)
|
|
|
wg := &sync.WaitGroup{}
|
|
|
total, isok := 0, 0
|
|
@@ -47,11 +55,17 @@ func RunPurchasingInfo(gtid string, lteid string) {
|
|
|
<-pool
|
|
|
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 {
|
|
|
numlock.Lock()
|
|
|
isok++
|
|
|
- ul.Mgo.UpdateById(ul.S_Bidding_Coll, class.BsonTOStringId(tmp["_id"]), map[string]interface{}{
|
|
|
+ ul.Mgo.UpdateById(ul.U_Bidding_Coll, class.BsonTOStringId(tmp["_id"]), map[string]interface{}{
|
|
|
"$set": map[string]interface{}{
|
|
|
"bid_field": "0101",
|
|
|
},
|
|
@@ -67,17 +81,18 @@ func RunPurchasingInfo(gtid string, lteid string) {
|
|
|
}
|
|
|
|
|
|
//构建标的物基本信息~模式一~规则型
|
|
|
-func createBaseInfo(tmp map[string]interface{}) bool {
|
|
|
+func createBaseInfo(tmp map[string]interface{}, infoid string) bool {
|
|
|
p_list := IsMarkInterfaceMap(tmp["purchasinglist"])
|
|
|
new_plist := []map[string]interface{}{}
|
|
|
- infoid := class.BsonTOStringId(tmp["_id"])
|
|
|
bid_topsubtype_code := confrimTopSubCode(qu.ObjToString(tmp["toptype"]), qu.ObjToString(tmp["subtype"]))
|
|
|
industry_code := confrimIndustryCode(qu.ObjToString(tmp["s_topscopeclass"]), qu.ObjToString(tmp["s_subscopeclass"]))
|
|
|
- isField := IsMedicalIndustryFieldInfo(tmp)
|
|
|
+ isField := IsMedicalFieldInfoRuleFirst(tmp)
|
|
|
if isField {
|
|
|
- _, new_plist = createNewPurchasingInfo(p_list)
|
|
|
- } else { //其他规则~验证是否能~通过验证
|
|
|
- isField, new_plist = createNewPurchasingInfo(p_list)
|
|
|
+ _, new_plist = createNewPurchasingInfo(p_list, infoid)
|
|
|
+ } else {
|
|
|
+ if IsMedicalFieldInfoRuleSecond(tmp) {
|
|
|
+ isField, new_plist = createNewPurchasingInfo(p_list, infoid)
|
|
|
+ }
|
|
|
}
|
|
|
if isField { //最终根据是否为领域数据灌入数据
|
|
|
//标的物基本信息~记录标签
|
|
@@ -88,13 +103,25 @@ func createBaseInfo(tmp map[string]interface{}) bool {
|
|
|
insertIndustryTag(industry_code, infoid)
|
|
|
}
|
|
|
|
|
|
+ //临时处理
|
|
|
+ //isField, new_plist := createNewPurchasingInfo(p_list, infoid)
|
|
|
+ //if isField { //最终根据是否为领域数据灌入数据
|
|
|
+ // //标的物基本信息~记录标签
|
|
|
+ // insertBaseInfo(new_plist, infoid, bid_topsubtype_code)
|
|
|
+ // //招标信息领域标签
|
|
|
+ // insertFiledTag(infoid)
|
|
|
+ // //招标信息行业标签
|
|
|
+ // insertIndustryTag(industry_code, infoid)
|
|
|
+ //}
|
|
|
+
|
|
|
//阻止注释~报错
|
|
|
- //if infoid == "" || bid_topsubtype_code == "" || industry_code == "" || len(new_plist) == 0 {}
|
|
|
+ //if bid_topsubtype_code == "" || industry_code == "" || len(new_plist) == 0 {}
|
|
|
+
|
|
|
return isField
|
|
|
}
|
|
|
|
|
|
//返回新的~标的物信息(分类+整合)
|
|
|
-func createNewPurchasingInfo(p_list []map[string]interface{}) (bool, []map[string]interface{}) {
|
|
|
+func createNewPurchasingInfo(p_list []map[string]interface{}, infoid string) (bool, []map[string]interface{}) {
|
|
|
new_plist := []map[string]interface{}{}
|
|
|
isExists := false
|
|
|
for _, v := range p_list {
|
|
@@ -105,8 +132,7 @@ func createNewPurchasingInfo(p_list []map[string]interface{}) (bool, []map[strin
|
|
|
continue
|
|
|
}
|
|
|
//根据标的物名字~打上具体的分类数据~
|
|
|
- //重要重要重要
|
|
|
- yl_code := confrimTargetMedicalClass(itemname)
|
|
|
+ yl_code := confrimTargetMedicalClass(itemname, infoid)
|
|
|
if yl_code != "" {
|
|
|
isExists = true
|
|
|
}
|
|
@@ -144,18 +170,29 @@ func createNewPurchasingInfo(p_list []map[string]interface{}) (bool, []map[strin
|
|
|
}
|
|
|
|
|
|
//是否为医疗行业数据
|
|
|
-func IsMedicalIndustryFieldInfo(tmp map[string]interface{}) 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
|
|
@@ -165,12 +202,24 @@ func isFieldInfoMethodFirst(top_class string, sub_class string, buyer_class stri
|
|
|
if !is_A {
|
|
|
return false
|
|
|
}
|
|
|
- if B_FieldReg.MatchString(buyer_class) || (buyer_class == "制造业" && strings.Contains(buyer, "医疗器械")) {
|
|
|
+ if B_FieldReg.MatchString(buyer_class) || (buyer_class == "制造业" && strings.Contains(buyer, "医疗器械") && strings.Contains(buyer, "公司")) {
|
|
|
is_B = true
|
|
|
}
|
|
|
- if !is_B {
|
|
|
+ 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
|
|
|
}
|
|
|
|