feat: property改为classmethod
This commit is contained in:
parent
8435b35be6
commit
c3bd32ee68
|
@ -143,8 +143,8 @@ class MIOItem(BaseModel):
|
||||||
|
|
||||||
is_testok = models.BooleanField('检验是否合格', default=True)
|
is_testok = models.BooleanField('检验是否合格', default=True)
|
||||||
|
|
||||||
@property
|
@classmethod
|
||||||
def count_fields(self):
|
def count_fields(cls):
|
||||||
mioitem_count_fields = []
|
mioitem_count_fields = []
|
||||||
for f in MIOItem._meta.fields:
|
for f in MIOItem._meta.fields:
|
||||||
if f.name.startswith("count"):
|
if f.name.startswith("count"):
|
||||||
|
|
|
@ -153,8 +153,8 @@ class FtestWork(CommonBDModel):
|
||||||
note = models.TextField('备注', null=True, blank=True)
|
note = models.TextField('备注', null=True, blank=True)
|
||||||
equipment = models.ForeignKey(Equipment, verbose_name='所属检验设备', on_delete=models.SET_NULL, null=True, blank=True)
|
equipment = models.ForeignKey(Equipment, verbose_name='所属检验设备', on_delete=models.SET_NULL, null=True, blank=True)
|
||||||
|
|
||||||
@property
|
@classmethod
|
||||||
def count_fields(self):
|
def count_fields(cls):
|
||||||
ftestwork_count_fields = []
|
ftestwork_count_fields = []
|
||||||
for f in FtestWork._meta.fields:
|
for f in FtestWork._meta.fields:
|
||||||
if f.name.startswith("count"):
|
if f.name.startswith("count"):
|
||||||
|
|
|
@ -285,8 +285,8 @@ class Mlog(CommonADModel):
|
||||||
return ['create_by', 'update_by',
|
return ['create_by', 'update_by',
|
||||||
'create_time', 'update_time', 'id']
|
'create_time', 'update_time', 'id']
|
||||||
|
|
||||||
@property
|
@classmethod
|
||||||
def count_fields(self):
|
def count_fields(cls):
|
||||||
mlog_count_fields = []
|
mlog_count_fields = []
|
||||||
for f in Mlog._meta.fields:
|
for f in Mlog._meta.fields:
|
||||||
if f.name.startswith("count"):
|
if f.name.startswith("count"):
|
||||||
|
|
|
@ -14,7 +14,7 @@ def get_alldata_with_batch(batch: str):
|
||||||
mgroup_blcx = Mgroup.objects.get(name="棒料成型")
|
mgroup_blcx = Mgroup.objects.get(name="棒料成型")
|
||||||
mlogs_blcx_qs = Mlog.objects.filter(submit_time__isnull=False, mgroup=mgroup_blcx, batch=batch)
|
mlogs_blcx_qs = Mlog.objects.filter(submit_time__isnull=False, mgroup=mgroup_blcx, batch=batch)
|
||||||
|
|
||||||
mlog_count_fields = Mlog.count_fields
|
mlog_count_fields = Mlog.count_fields()
|
||||||
|
|
||||||
if mlogs_blcx_qs.exists():
|
if mlogs_blcx_qs.exists():
|
||||||
data["产品规格"] = []
|
data["产品规格"] = []
|
||||||
|
@ -43,7 +43,7 @@ def get_alldata_with_batch(batch: str):
|
||||||
data["棒料成型-合格率"] = round((data["棒料成型-count_ok"] * 100/ data["棒料成型-count_real"]), 1)
|
data["棒料成型-合格率"] = round((data["棒料成型-count_ok"] * 100/ data["棒料成型-count_real"]), 1)
|
||||||
|
|
||||||
# 7车间生产入库数据/ 8车间中检数据
|
# 7车间生产入库数据/ 8车间中检数据
|
||||||
mioitem_count_fields = MIOItem.count_fields
|
mioitem_count_fields = MIOItem.count_fields()
|
||||||
mioitem_qs = MIOItem.objects.filter(mio__belong_dept=dept7, mio__type="do_in", batch=batch, mio__submit_time__isnull=False)
|
mioitem_qs = MIOItem.objects.filter(mio__belong_dept=dept7, mio__type="do_in", batch=batch, mio__submit_time__isnull=False)
|
||||||
if mioitem_qs.exists():
|
if mioitem_qs.exists():
|
||||||
data["7车间入库-日期"] = []
|
data["7车间入库-日期"] = []
|
||||||
|
@ -125,7 +125,7 @@ def get_alldata_with_batch(batch: str):
|
||||||
# data["6车间生产入库-日期"] = ";".join([item.strftime("%Y-%m-%d") for item in data["6车间生产入库-日期"]])
|
# data["6车间生产入库-日期"] = ";".join([item.strftime("%Y-%m-%d") for item in data["6车间生产入库-日期"]])
|
||||||
|
|
||||||
# 成品检验数据
|
# 成品检验数据
|
||||||
ftestwork_count_fields = FtestWork.count_fields
|
ftestwork_count_fields = FtestWork.count_fields()
|
||||||
ftestwork_qs = FtestWork.objects.filter(batch=batch)
|
ftestwork_qs = FtestWork.objects.filter(batch=batch)
|
||||||
if ftestwork_qs.exists():
|
if ftestwork_qs.exists():
|
||||||
data["成品检验-日期"] = []
|
data["成品检验-日期"] = []
|
||||||
|
|
Loading…
Reference in New Issue