|
@@ -29,11 +29,11 @@ func RunPurchasingInfo(gtid string, lteid string) {
|
|
|
},
|
|
|
}
|
|
|
it := sess.DB(ul.Mgo.DbName).C(ul.S_Bidding_Coll).Find(&q).Sort("_id").Select(fields).Iter()
|
|
|
- pool := make(chan bool, 6)
|
|
|
+ pool := make(chan bool, 8)
|
|
|
wg := &sync.WaitGroup{}
|
|
|
total, isok := 0, 0
|
|
|
for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
|
|
|
- if total%10000 == 0 {
|
|
|
+ if total%1000 == 0 {
|
|
|
log.Debug("cur index ", total, "~", isok)
|
|
|
}
|
|
|
if qu.IntAll(tmp["extracttype"]) != 1 {
|
|
@@ -47,16 +47,15 @@ func RunPurchasingInfo(gtid string, lteid string) {
|
|
|
<-pool
|
|
|
wg.Done()
|
|
|
}()
|
|
|
- //构建标的物基本信息
|
|
|
- b := createBaseInfo(tmp)
|
|
|
+ b := createBaseInfo(tmp) //构建信息
|
|
|
if b {
|
|
|
numlock.Lock()
|
|
|
isok++
|
|
|
- //ul.Mgo.UpdateById(ul.S_Bidding_Coll, class.BsonTOStringId(tmp["_id"]), map[string]interface{}{
|
|
|
- // "$set": map[string]interface{}{
|
|
|
- // "bid_field": "0101",
|
|
|
- // },
|
|
|
- //})
|
|
|
+ ul.Mgo.UpdateById(ul.S_Bidding_Coll, class.BsonTOStringId(tmp["_id"]), map[string]interface{}{
|
|
|
+ "$set": map[string]interface{}{
|
|
|
+ "bid_field": "0101",
|
|
|
+ },
|
|
|
+ })
|
|
|
numlock.Unlock()
|
|
|
}
|
|
|
}(tmp)
|
|
@@ -67,19 +66,20 @@ func RunPurchasingInfo(gtid string, lteid string) {
|
|
|
log.Debug("is over ", total, "~", isok)
|
|
|
}
|
|
|
|
|
|
-//构建标的物基本信息
|
|
|
+//构建标的物基本信息~模式一~规则型
|
|
|
func createBaseInfo(tmp map[string]interface{}) bool {
|
|
|
p_list := IsMarkInterfaceMap(tmp["purchasinglist"])
|
|
|
+ new_plist := []map[string]interface{}{}
|
|
|
infoid := class.BsonTOStringId(tmp["_id"])
|
|
|
- s_topscopeclass := qu.ObjToString(tmp["s_topscopeclass"])
|
|
|
- s_subscopeclass := qu.ObjToString(tmp["s_subscopeclass"])
|
|
|
- buyerclass := qu.ObjToString(tmp["buyerclass"])
|
|
|
- buyer := qu.ObjToString(tmp["buyer"])
|
|
|
bid_topsubtype_code := confrimTopSubCode(qu.ObjToString(tmp["toptype"]), qu.ObjToString(tmp["subtype"]))
|
|
|
- //是否符合领域范围
|
|
|
- industry_code, isField := IsIndustryInfo(s_topscopeclass, s_subscopeclass, buyerclass, buyer)
|
|
|
+ industry_code := confrimIndustryCode(qu.ObjToString(tmp["s_topscopeclass"]), qu.ObjToString(tmp["s_subscopeclass"]))
|
|
|
+ isField := IsMedicalIndustryFieldInfo(tmp)
|
|
|
if isField {
|
|
|
- new_plist := createNewPurchasingInfo(p_list)
|
|
|
+ _, new_plist = createNewPurchasingInfo(p_list)
|
|
|
+ } else { //其他规则~验证是否能~通过验证
|
|
|
+ isField, new_plist = createNewPurchasingInfo(p_list)
|
|
|
+ }
|
|
|
+ if isField { //最终根据是否为领域数据灌入数据
|
|
|
//标的物基本信息~记录标签
|
|
|
insertBaseInfo(new_plist, infoid, bid_topsubtype_code)
|
|
|
//招标信息领域标签
|
|
@@ -87,12 +87,16 @@ func createBaseInfo(tmp map[string]interface{}) bool {
|
|
|
//招标信息行业标签
|
|
|
insertIndustryTag(industry_code, infoid)
|
|
|
}
|
|
|
+
|
|
|
+ //阻止注释~报错
|
|
|
+ //if infoid == "" || bid_topsubtype_code == "" || industry_code == "" || len(new_plist) == 0 {}
|
|
|
return isField
|
|
|
}
|
|
|
|
|
|
//返回新的~标的物信息(分类+整合)
|
|
|
-func createNewPurchasingInfo(p_list []map[string]interface{}) []map[string]interface{} {
|
|
|
+func createNewPurchasingInfo(p_list []map[string]interface{}) (bool, []map[string]interface{}) {
|
|
|
new_plist := []map[string]interface{}{}
|
|
|
+ isExists := false
|
|
|
for _, v := range p_list {
|
|
|
//去重处理~名称~品牌~型号~暂无重复
|
|
|
data := map[string]interface{}{}
|
|
@@ -103,7 +107,9 @@ func createNewPurchasingInfo(p_list []map[string]interface{}) []map[string]inter
|
|
|
//根据标的物名字~打上具体的分类数据~
|
|
|
//重要重要重要
|
|
|
yl_code := confrimTargetMedicalClass(itemname)
|
|
|
-
|
|
|
+ if yl_code != "" {
|
|
|
+ isExists = true
|
|
|
+ }
|
|
|
data["medical_equipment_code"] = yl_code
|
|
|
data["itemname"] = itemname
|
|
|
data["brand"] = qu.ObjToString(v["brandname"])
|
|
@@ -134,27 +140,43 @@ func createNewPurchasingInfo(p_list []map[string]interface{}) []map[string]inter
|
|
|
}
|
|
|
new_plist = append(new_plist, data)
|
|
|
}
|
|
|
- return new_plist
|
|
|
+ return isExists, new_plist
|
|
|
}
|
|
|
|
|
|
//是否为医疗行业数据
|
|
|
-func IsIndustryInfo(top_class string, sub_class string, buyer_class string, buyer string) (string, bool) {
|
|
|
- code := ""
|
|
|
- //两组条件判断是否为医疗领域数据~
|
|
|
+func IsMedicalIndustryFieldInfo(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 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
|
|
|
+ return false
|
|
|
}
|
|
|
if B_FieldReg.MatchString(buyer_class) || (buyer_class == "制造业" && strings.Contains(buyer, "医疗器械")) {
|
|
|
is_B = true
|
|
|
}
|
|
|
if !is_B {
|
|
|
- return "", false
|
|
|
+ return false
|
|
|
}
|
|
|
- //拼接code
|
|
|
+ return is_A && is_B
|
|
|
+}
|
|
|
+
|
|
|
+//确认行业code
|
|
|
+func confrimIndustryCode(top_class string, sub_class string) string {
|
|
|
+ code := ""
|
|
|
top_arr := strings.Split(top_class, ",")
|
|
|
for _, v := range top_arr {
|
|
|
vc := ul.Bid_Industry[v]["code"]
|
|
@@ -176,7 +198,7 @@ func IsIndustryInfo(top_class string, sub_class string, buyer_class string, buye
|
|
|
code += vc
|
|
|
}
|
|
|
}
|
|
|
- return code, true
|
|
|
+ return code
|
|
|
}
|
|
|
|
|
|
//根据标的物名称~打医疗分类
|