Compare commits
No commits in common. "27416dfeaaf7c29f75ef99669a2902502845f016" and "f6f842c17f6e3f94dc1cab3fe7fd007b3ddf789d" have entirely different histories.
27416dfeaa
...
f6f842c17f
|
|
@ -61,7 +61,8 @@ class WMaterialFilter(filters.FilterSet):
|
||||||
qs = queryset.filter(material__id__in=matoutIds).exclude(state=WMaterial.WM_REPAIR)|queryset.filter(state=WMaterial.WM_REPAIRED, mgroup__id=mgroupId)
|
qs = queryset.filter(material__id__in=matoutIds).exclude(state=WMaterial.WM_REPAIR)|queryset.filter(state=WMaterial.WM_REPAIRED, mgroup__id=mgroupId)
|
||||||
elif value == "canfix":
|
elif value == "canfix":
|
||||||
matoutIds = process.get_canout_mat_ids()
|
matoutIds = process.get_canout_mat_ids()
|
||||||
qs = queryset.filter(state=WMaterial.WM_REPAIR, mgroup__id=mgroupId)| queryset.filter(material__id__in=matoutIds, state=WMaterial.WM_NOTOK)
|
qs = queryset.filter(state=WMaterial.WM_REPAIR, mgroup__id=mgroupId)| queryset.filter(material__id__in=matoutIds, state=WMaterial.WM_NOTOK).exclude(
|
||||||
|
state=WMaterial.WM_REPAIR).exclude(state=WMaterial.WM_REPAIRED)
|
||||||
return qs
|
return qs
|
||||||
else:
|
else:
|
||||||
raise ParseError("请提供工段查询条件")
|
raise ParseError("请提供工段查询条件")
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,14 @@
|
||||||
from django_filters import rest_framework as filters
|
from django_filters import rest_framework as filters
|
||||||
from apps.wpm.models import (Handoverbw, Mlogbw, WMaterial)
|
from apps.wpm.models import (Handoverbw, Mlogbw)
|
||||||
from apps.inm.models import MIOItemw
|
from apps.inm.models import MIOItemw
|
||||||
from apps.wpmw.models import Wpr
|
from apps.wpmw.models import Wpr
|
||||||
from apps.mtm.models import Route, Material, Mgroup
|
from apps.mtm.models import Route, Material
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from rest_framework.exceptions import ParseError
|
from rest_framework.exceptions import ParseError
|
||||||
|
|
||||||
|
|
||||||
class WprFilter(filters.FilterSet):
|
class WprFilter(filters.FilterSet):
|
||||||
can_use = filters.CharFilter(method='filter_can_use')
|
can_use = filters.CharFilter(method='filter_can_use')
|
||||||
mgroupx = filters.CharFilter(label='MgroupId', method='filter_mgroupx')
|
|
||||||
tag = filters.CharFilter(label="todo/done", method="filter_tag")
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Wpr
|
model = Wpr
|
||||||
fields = {
|
fields = {
|
||||||
|
|
@ -21,28 +19,6 @@ class WprFilter(filters.FilterSet):
|
||||||
"defects": ["exact"],
|
"defects": ["exact"],
|
||||||
"number": ["exact"]
|
"number": ["exact"]
|
||||||
}
|
}
|
||||||
|
|
||||||
def filter_mgroupx(self, queryset, name, value):
|
|
||||||
return queryset.filter(wm__in=WMaterial.ava_qs(mgroup=Mgroup.objects.get(id=value)))
|
|
||||||
|
|
||||||
def filter_tag(self, queryset, name, value):
|
|
||||||
mgroupId = self.data.get("mgroupx", None)
|
|
||||||
if mgroupId:
|
|
||||||
process = Mgroup.objects.get(id=mgroupId).process
|
|
||||||
|
|
||||||
queryset = queryset.filter(material__type__in=[Material.MA_TYPE_MAINSO, Material.MA_TYPE_HALFGOOD, Material.MA_TYPE_GOOD])
|
|
||||||
if value == "todo":
|
|
||||||
matIds = process.get_canin_mat_ids()
|
|
||||||
qs = queryset.filter(material__id__in=matIds).exclude(state=WMaterial.WM_REPAIRED)|queryset.filter(state=WMaterial.WM_REPAIR, wm__mgroup__id=mgroupId)
|
|
||||||
return qs
|
|
||||||
elif value == "done":
|
|
||||||
matoutIds = process.get_canout_mat_ids()
|
|
||||||
qs = queryset.filter(material__id__in=matoutIds).exclude(state=WMaterial.WM_REPAIR)|queryset.filter(state=WMaterial.WM_REPAIRED, wm__mgroup__id=mgroupId)
|
|
||||||
elif value == "canfix":
|
|
||||||
matoutIds = process.get_canout_mat_ids()
|
|
||||||
qs = queryset.filter(state=WMaterial.WM_REPAIR, wm__mgroup__id=mgroupId)| queryset.filter(material__id__in=matoutIds, state=WMaterial.WM_NOTOK)
|
|
||||||
else:
|
|
||||||
raise ParseError("请提供工段查询条件")
|
|
||||||
|
|
||||||
def filter_can_use(self, queryset, name, value):
|
def filter_can_use(self, queryset, name, value):
|
||||||
if value == 'yes':
|
if value == 'yes':
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue