| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- #coding=utf-8
- '''
- Created on 2016年6月6日
- @author: uas
- '''
- from util_common import Constant
- from analysis import detail_analysis
- from pymongo.mongo_client import MongoClient
- detail_analysis_main=detail_analysis.DetailAnalysis()
- cli=MongoClient(Constant.MONGODB_URL)
- db=cli.spider
- detail_analysis_main._handle_kind(db)
- ###
- ### Create property table
- # property_set = set()
- # detail_cmp = db.component_origianl.find()
- # for detail_json in detail_cmp:
- # property_list = detail_json["properties"]
- # for pro in property_list:
- # '''
- # @todo 之前写错了,这里在后面需要改为
- # label = pro["label"]
- # '''
- # label = pro["label"]
- # property_set.add(label)
- #
- # for index, pro in enumerate(property_set):
- # d = dict()
- # d["id"] = index + 1
- # d["labelCn"] = pro
- # db.property_0606.insert_one(d)
- #
- # ###
- # ###
- # ### 生成property_value 表
- #
- #
- # temp_property = db.property_0606.find()
- # property_list = list()
- # for kind in temp_property:
- # property_list.append(kind)
- #
- # def _get_propertyid_by_label(label):
- # for pro in property_list:
- # if pro["labelCn"] == label:
- # return pro["id"]
- #
- # for detail_kindid in detail_cmp:
- # componentid = detail_kindid["id"]
- # propertyValues = detail_kindid["properties"]
- # for inde, propertyValue in enumerate(propertyValues):
- # d = dict()
- # d["componentid"] = componentid
- # d["propertyid"] = _get_propertyid_by_label(propertyValue["lable"])
- # d["detno"] = inde + 1
- # d["value"] = propertyValue["value"]
- # db.propertyvalue_0606.insert_one(d)
- # brand_set = set()
- # rs_brand = db.propertyvalue.find({"propertyid" : 40})
- # for propertyvalue in rs_brand:
- # brand_set.add(propertyvalue["value"])
- #
- # brand_list = list()
- # for index, brandName in enumerate(brand_set):
- # d = dict()
- # d["id"] = index + 1
- # d["nameEn"] = brandName
- # # 因为系统全部用的Cn,所以这里先装模作样地赋值
- # d["nameCn"] = brandName
- # brand_list.append(d)
- # db.brand_0606.insert_many(brand_list)
-
- # detail_analysis_main._create_property(db)
- #
- # detail_analysis_main._create_propertyvalue(db)
- #
- # detail_analysis_main._handle_brand(db)
|