pre_adaptive_cameras

huangqimin vor 5 Jahren
Ursprung
Commit
2e20a894a3
3 geänderte Dateien mit 36 neuen Zeilen und 1 gelöschten Zeilen
  1. BIN
      pre/static/models_20180816.xls
  2. BIN
      pre/static/腾龙镜头适用机型V1.xlsx
  3. 36 1
      pre/views.py

BIN
pre/static/models_20180816.xls


BIN
pre/static/腾龙镜头适用机型V1.xlsx


+ 36 - 1
pre/views.py

@@ -7,7 +7,7 @@ from django.conf import settings
7 7
 from pysnippets.strsnippets import strip
8 8
 from TimeConvert import TimeConvert as tc
9 9
 
10
-from mch.models import BrandInfo, ConsumeInfoSubmitLogInfo, DistributorInfo, ModelInfo
10
+from mch.models import BrandInfo, ConsumeInfoSubmitLogInfo, DistributorInfo, ModelInfo, ModelCameraBodyInfo
11 11
 from statistic.models import (ConsumeDistributorSaleStatisticInfo, ConsumeModelSaleStatisticInfo,
12 12
                               ConsumeProvinceSaleStatisticInfo, ConsumeSaleStatisticInfo, ConsumeUserStatisticInfo,
13 13
                               DistributorSaleStatisticInfo, ModelSaleStatisticInfo, ProvinceSaleStatisticInfo,
@@ -142,6 +142,41 @@ def pre_new_models(fpath='./pre/static/models_20180816.xls'):
142 142
         mdl.save()
143 143
 
144 144
 
145
+def pre_adaptive_cameras(fpath=u'./pre/static/腾龙镜头适用机型V1.xlsx'):
146
+    ModelCameraBodyInfo.objects.all().delete()
147
+
148
+    workbook = xlrd.open_workbook(fpath)
149
+    # sheet = workbook.sheet_by_name('SMR')
150
+    # import ipdb;ipdb.set_trace()
151
+    sheets = workbook.sheets()
152
+    # Deal sheet0
153
+    sheet0 = sheets[0]
154
+    # Deal sheet1-n
155
+    sheets = sheets[1:]
156
+    for sheet in sheets:
157
+        model_name = sheet.name
158
+        model_full_name = sheet.row_values(2)[0]
159
+        print model_name, model_full_name
160
+        nrows = sheet.nrows
161
+        for idx in range(4, nrows):
162
+            rvals = sheet.row_values(idx)
163
+            print rvals
164
+            for val in rvals:
165
+                val = strip(val)
166
+                if not val:
167
+                    continue
168
+                if u'卡口' in val:
169
+                    continue
170
+                print val
171
+                ModelCameraBodyInfo.objects.get_or_create(
172
+                    brand_id=settings.KODO_DEFAULT_BRAND_ID,
173
+                    brand_name=settings.KODO_DEFAULT_BRAND_NAME,
174
+                    model_name=model_name,
175
+                    model_full_name=model_full_name,
176
+                    camera_name=val,
177
+                )
178
+
179
+
145 180
 def fill_ym():
146 181
     for o in ConsumeSaleStatisticInfo.objects.all():
147 182
         ymd = str(o.ymd)