testUpdate.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #coding=utf-8
  2. '''
  3. Created on 2016年6月6日
  4. @author: uas
  5. '''
  6. from util_common import Constant
  7. from analysis import detail_analysis
  8. from pymongo.mongo_client import MongoClient
  9. detail_analysis_main=detail_analysis.DetailAnalysis()
  10. cli=MongoClient(Constant.MONGODB_URL)
  11. db=cli.spider
  12. detail_analysis_main._handle_kind(db)
  13. ###
  14. ### Create property table
  15. # property_set = set()
  16. # detail_cmp = db.component_origianl.find()
  17. # for detail_json in detail_cmp:
  18. # property_list = detail_json["properties"]
  19. # for pro in property_list:
  20. # '''
  21. # @todo 之前写错了,这里在后面需要改为
  22. # label = pro["label"]
  23. # '''
  24. # label = pro["label"]
  25. # property_set.add(label)
  26. #
  27. # for index, pro in enumerate(property_set):
  28. # d = dict()
  29. # d["id"] = index + 1
  30. # d["labelCn"] = pro
  31. # db.property_0606.insert_one(d)
  32. #
  33. # ###
  34. # ###
  35. # ### 生成property_value 表
  36. #
  37. #
  38. # temp_property = db.property_0606.find()
  39. # property_list = list()
  40. # for kind in temp_property:
  41. # property_list.append(kind)
  42. #
  43. # def _get_propertyid_by_label(label):
  44. # for pro in property_list:
  45. # if pro["labelCn"] == label:
  46. # return pro["id"]
  47. #
  48. # for detail_kindid in detail_cmp:
  49. # componentid = detail_kindid["id"]
  50. # propertyValues = detail_kindid["properties"]
  51. # for inde, propertyValue in enumerate(propertyValues):
  52. # d = dict()
  53. # d["componentid"] = componentid
  54. # d["propertyid"] = _get_propertyid_by_label(propertyValue["lable"])
  55. # d["detno"] = inde + 1
  56. # d["value"] = propertyValue["value"]
  57. # db.propertyvalue_0606.insert_one(d)
  58. # brand_set = set()
  59. # rs_brand = db.propertyvalue.find({"propertyid" : 40})
  60. # for propertyvalue in rs_brand:
  61. # brand_set.add(propertyvalue["value"])
  62. #
  63. # brand_list = list()
  64. # for index, brandName in enumerate(brand_set):
  65. # d = dict()
  66. # d["id"] = index + 1
  67. # d["nameEn"] = brandName
  68. # # 因为系统全部用的Cn,所以这里先装模作样地赋值
  69. # d["nameCn"] = brandName
  70. # brand_list.append(d)
  71. # db.brand_0606.insert_many(brand_list)
  72. # detail_analysis_main._create_property(db)
  73. #
  74. # detail_analysis_main._create_propertyvalue(db)
  75. #
  76. # detail_analysis_main._handle_brand(db)