@@ -62,7 +62,7 @@ def pre_provinces(): |
||
| 62 | 62 |
def pre_models(): |
| 63 | 63 |
brands = BrandInfo.objects.filter(status=True) |
| 64 | 64 |
for brand in brands: |
| 65 |
- models = ModelInfo.objects.filter(status=True) |
|
| 65 |
+ models = ModelInfo.objects.filter(brand_id=brand.brand_id, status=True) |
|
| 66 | 66 |
for mdl in models: |
| 67 | 67 |
mssi, created = ModelSaleStatisticInfo.objects.get_or_create(brand_id=brand.brand_id, model_id=mdl.model_id, ymd=0) |
| 68 | 68 |
mssi.model_name = mdl.model_name |
@@ -76,7 +76,7 @@ def pre_models(): |
||
| 76 | 76 |
def pre_distributors(): |
| 77 | 77 |
brands = BrandInfo.objects.filter(status=True) |
| 78 | 78 |
for brand in brands: |
| 79 |
- distributors = DistributorInfo.objects.filter(status=True) |
|
| 79 |
+ distributors = DistributorInfo.objects.filter(brand_id=brand.brand_id, status=True) |
|
| 80 | 80 |
for dtbt in distributors: |
| 81 | 81 |
dssi, created = DistributorSaleStatisticInfo.objects.get_or_create(brand_id=brand.brand_id, distributor_id=dtbt.distributor_id, ymd=0) |
| 82 | 82 |
dssi.distributor_name = dtbt.distributor_name |
@@ -3,10 +3,11 @@ |
||
| 3 | 3 |
from django.conf import settings |
| 4 | 4 |
from django.db import transaction |
| 5 | 5 |
from django_logit import logit |
| 6 |
+from django_models_ext.provincemodels import ProvinceShortModelMixin |
|
| 6 | 7 |
from django_response import response |
| 7 | 8 |
from TimeConvert import TimeConvert as tc |
| 8 | 9 |
|
| 9 |
-from mch.models import BrandInfo |
|
| 10 |
+from mch.models import BrandInfo, DistributorInfo, ModelInfo |
|
| 10 | 11 |
from statistic.models import (ConsumeDistributorSaleStatisticInfo, ConsumeModelSaleStatisticInfo, |
| 11 | 12 |
ConsumeProvinceSaleStatisticInfo, ConsumeSaleStatisticInfo, DistributorSaleStatisticInfo, |
| 12 | 13 |
ModelSaleStatisticInfo, ProvinceSaleStatisticInfo, RegisterStatisticInfo, |
@@ -126,6 +127,59 @@ def tj_generate(request): |
||
| 126 | 127 |
brands = BrandInfo.objects.filter(status=True) |
| 127 | 128 |
|
| 128 | 129 |
for brand in brands: |
| 130 |
+ for pcode, pname in ProvinceShortModelMixin.PROVINCE_CODE_NAME_DICT.items(): |
|
| 131 |
+ pssi, created = ProvinceSaleStatisticInfo.objects.get_or_create( |
|
| 132 |
+ brand_id=brand.brand_id, |
|
| 133 |
+ province_code=pcode, |
|
| 134 |
+ ymd=ymd, |
|
| 135 |
+ ) |
|
| 136 |
+ pssi.province_name = pname |
|
| 137 |
+ pssi.save() |
|
| 138 |
+ |
|
| 139 |
+ cpssi, created = ConsumeProvinceSaleStatisticInfo.objects.get_or_create( |
|
| 140 |
+ brand_id=brand.brand_id, |
|
| 141 |
+ province_code=pcode, |
|
| 142 |
+ ymd=ymd, |
|
| 143 |
+ ) |
|
| 144 |
+ cpssi.province_name = pname |
|
| 145 |
+ cpssi.save() |
|
| 146 |
+ |
|
| 147 |
+ models = ModelInfo.objects.filter(brand_id=brand.brand_id, status=True) |
|
| 148 |
+ for mdl in models: |
|
| 149 |
+ mssi, created = ModelSaleStatisticInfo.objects.get_or_create( |
|
| 150 |
+ brand_id=brand.brand_id, |
|
| 151 |
+ model_id=mdl.model_id, |
|
| 152 |
+ ymd=ymd, |
|
| 153 |
+ ) |
|
| 154 |
+ mssi.model_name = mdl.model_name |
|
| 155 |
+ mssi.save() |
|
| 156 |
+ |
|
| 157 |
+ cmssi, created = ConsumeModelSaleStatisticInfo.objects.get_or_create( |
|
| 158 |
+ brand_id=brand.brand_id, |
|
| 159 |
+ model_id=mdl.model_id, |
|
| 160 |
+ ymd=ymd, |
|
| 161 |
+ ) |
|
| 162 |
+ cmssi.model_name = mdl.model_name |
|
| 163 |
+ cmssi.save() |
|
| 164 |
+ |
|
| 165 |
+ distributors = DistributorInfo.objects.filter(brand_id=brand.brand_id, status=True) |
|
| 166 |
+ for dtbt in distributors: |
|
| 167 |
+ dssi, created = DistributorSaleStatisticInfo.objects.get_or_create( |
|
| 168 |
+ brand_id=brand.brand_id, |
|
| 169 |
+ distributor_id=dtbt.distributor_id, |
|
| 170 |
+ ymd=ymd, |
|
| 171 |
+ ) |
|
| 172 |
+ dssi.distributor_name = dtbt.distributor_name |
|
| 173 |
+ dssi.save() |
|
| 174 |
+ |
|
| 175 |
+ cdssi, created = ConsumeDistributorSaleStatisticInfo.objects.get_or_create( |
|
| 176 |
+ brand_id=brand.brand_id, |
|
| 177 |
+ distributor_id=dtbt.distributor_id, |
|
| 178 |
+ ymd=ymd, |
|
| 179 |
+ ) |
|
| 180 |
+ cdssi.distributor_name = dtbt.distributor_name |
|
| 181 |
+ cdssi.save() |
|
| 182 |
+ |
|
| 129 | 183 |
RegisterStatisticInfo.objects.select_for_update().get_or_create( |
| 130 | 184 |
brand_id=brand.brand_id, |
| 131 | 185 |
ymd=ymd, |