feat: material的count改为对所有库存进行统计
This commit is contained in:
parent
9b2dbb8a01
commit
19f6e18154
|
@ -44,10 +44,3 @@ def correct_mb_count_notok():
|
||||||
InmService.update_mb_after_test(mi)
|
InmService.update_mb_after_test(mi)
|
||||||
except ParseError as e:
|
except ParseError as e:
|
||||||
MIOItem.objects.filter(id=mi.id).update(test_date=None)
|
MIOItem.objects.filter(id=mi.id).update(test_date=None)
|
||||||
|
|
||||||
|
|
||||||
def correct_material_count():
|
|
||||||
"""
|
|
||||||
矫正现有物料总数量
|
|
||||||
"""
|
|
||||||
res = MaterialBatch.objects.values('material').aggregate(total=Sum('count'))
|
|
|
@ -45,10 +45,14 @@ class InmService:
|
||||||
def cal_mat_count(cls, material: Material):
|
def cal_mat_count(cls, material: Material):
|
||||||
material_count = MaterialBatch.objects.filter(
|
material_count = MaterialBatch.objects.filter(
|
||||||
material=material).aggregate(total=Sum('count'))['total']
|
material=material).aggregate(total=Sum('count'))['total']
|
||||||
|
from apps.wpm.models import WMaterial
|
||||||
|
wm_count = WMaterial.objects.filter(material=material).aggregate(total=Sum('count'))['total']
|
||||||
if material_count is None:
|
if material_count is None:
|
||||||
material_count = 0
|
material_count = 0
|
||||||
|
if wm_count is None:
|
||||||
|
wm_count = 0
|
||||||
Material.objects.filter(id=material.id).update(
|
Material.objects.filter(id=material.id).update(
|
||||||
count=material_count)
|
count=material_count+wm_count)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def update_mb(cls, instance: MIO, in_or_out: int = 1):
|
def update_mb(cls, instance: MIO, in_or_out: int = 1):
|
||||||
|
|
|
@ -4,10 +4,14 @@ from celery import shared_task
|
||||||
from apps.mtm.models import Material
|
from apps.mtm.models import Material
|
||||||
|
|
||||||
@shared_task(base=CustomTask)
|
@shared_task(base=CustomTask)
|
||||||
def correct_material_count():
|
def correct_material_count(materialId: str = ''):
|
||||||
"""
|
"""
|
||||||
矫正现有物料总数量
|
矫正现有物料总数量
|
||||||
"""
|
"""
|
||||||
from apps.inm.services import InmService
|
from apps.inm.services import InmService
|
||||||
for m in Material.objects.all():
|
if materialId:
|
||||||
|
objs = Material.objects.filter(id=materialId)
|
||||||
|
else:
|
||||||
|
objs = Material.objects.all()
|
||||||
|
for m in objs:
|
||||||
InmService.cal_mat_count(m)
|
InmService.cal_mat_count(m)
|
Loading…
Reference in New Issue