Merge branch 'master' of http://gitea.xxhhcty.xyz:8080/zcdsj/factory
This commit is contained in:
commit
eca63e993d
|
|
@ -146,7 +146,9 @@ class DatasetRecordViewSet(ListModelMixin, CustomGenericViewSet):
|
||||||
queryset = DatasetRecord.objects.all()
|
queryset = DatasetRecord.objects.all()
|
||||||
serializer_class = DatasetRecordSerializer
|
serializer_class = DatasetRecordSerializer
|
||||||
filterset_fields = {
|
filterset_fields = {
|
||||||
"timex": ["year", "month", "day"]
|
"timex": ["year", "month", "day"],
|
||||||
|
"dataset": ["exact"],
|
||||||
|
"dataset__code": ["exact"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,10 @@ class Material(CommonAModel):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f'{self.name}|{self.specification if self.specification else ""}|{self.model if self.model else ""}|{self.process.name if self.process else ""}'
|
return f'{self.name}|{self.specification if self.specification else ""}|{self.model if self.model else ""}|{self.process.name if self.process else ""}'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def fname(self):
|
||||||
|
return f'{self.name}|{self.specification if self.specification else ""}|{self.model if self.model else ""}|{self.process.name if self.process else ""}'
|
||||||
|
|
||||||
|
|
||||||
class Shift(CommonBModel):
|
class Shift(CommonBModel):
|
||||||
"""TN:班次
|
"""TN:班次
|
||||||
|
|
|
||||||
|
|
@ -94,10 +94,10 @@ class BulkCreateModelMixin(CreateModelMixin):
|
||||||
for item in rdata:
|
for item in rdata:
|
||||||
if "id" in item and item["id"]:
|
if "id" in item and item["id"]:
|
||||||
raise ParseError('创建数据中不能包含id字段')
|
raise ParseError('创建数据中不能包含id字段')
|
||||||
|
many = True
|
||||||
else:
|
else:
|
||||||
if "id" in rdata and rdata["id"]:
|
if "id" in rdata and rdata["id"]:
|
||||||
raise ParseError('创建数据中不能包含id字段')
|
raise ParseError('创建数据中不能包含id字段')
|
||||||
many = True
|
|
||||||
sr = self.get_serializer(data=rdata, many=many)
|
sr = self.get_serializer(data=rdata, many=many)
|
||||||
sr.is_valid(raise_exception=True)
|
sr.is_valid(raise_exception=True)
|
||||||
self.perform_create(sr)
|
self.perform_create(sr)
|
||||||
|
|
|
||||||
|
|
@ -304,7 +304,7 @@ class WfService(object):
|
||||||
if ticket is None:
|
if ticket is None:
|
||||||
# 创建工单逻辑
|
# 创建工单逻辑
|
||||||
if transition:
|
if transition:
|
||||||
if transition.workflow.id != workflow.id:
|
if workflow and transition.workflow.id != workflow.id:
|
||||||
raise ParseError("当前流转不属于该工作流")
|
raise ParseError("当前流转不属于该工作流")
|
||||||
workflow = transition.workflow
|
workflow = transition.workflow
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1182,6 +1182,7 @@ class HandoverSerializer(CustomModelSerializer):
|
||||||
material_ = MaterialSimpleSerializer(source='material', read_only=True)
|
material_ = MaterialSimpleSerializer(source='material', read_only=True)
|
||||||
material_name = serializers.StringRelatedField(
|
material_name = serializers.StringRelatedField(
|
||||||
source='material', read_only=True)
|
source='material', read_only=True)
|
||||||
|
material_changed_fname = serializers.CharField(source='material_changed.fname', read_only=True)
|
||||||
wm_notok_sign = serializers.CharField(source='wm.notok_sign', read_only=True)
|
wm_notok_sign = serializers.CharField(source='wm.notok_sign', read_only=True)
|
||||||
handoverb = HandoverbSerializer(many=True, required=False)
|
handoverb = HandoverbSerializer(many=True, required=False)
|
||||||
ticket_ = TicketSimpleSerializer(source='ticket', read_only=True)
|
ticket_ = TicketSimpleSerializer(source='ticket', read_only=True)
|
||||||
|
|
@ -1189,13 +1190,15 @@ class HandoverSerializer(CustomModelSerializer):
|
||||||
def validate(self, attrs):
|
def validate(self, attrs):
|
||||||
if "mtype" not in attrs:
|
if "mtype" not in attrs:
|
||||||
attrs['mtype'] = Handover.H_NORMAL
|
attrs['mtype'] = Handover.H_NORMAL
|
||||||
mtype = attrs["mtype"]
|
|
||||||
if 'type' not in attrs:
|
if 'type' not in attrs:
|
||||||
attrs['type'] = Handover.H_NORMAL
|
attrs['type'] = Handover.H_NORMAL
|
||||||
|
|
||||||
if attrs["type"] == Handover.H_CHANGE:
|
if attrs["type"] == Handover.H_CHANGE:
|
||||||
|
attrs["mtype"] = Handover.H_MERGE
|
||||||
if "material_changed" not in attrs:
|
if "material_changed" not in attrs:
|
||||||
raise ParseError("必须指定改版后的物料")
|
raise ParseError("必须指定改版后的物料")
|
||||||
|
|
||||||
|
mtype = attrs["mtype"]
|
||||||
if mtype == Handover.H_MERGE:
|
if mtype == Handover.H_MERGE:
|
||||||
new_state = None
|
new_state = None
|
||||||
new_wm:WMaterial = attrs.get("new_wm", None)
|
new_wm:WMaterial = attrs.get("new_wm", None)
|
||||||
|
|
|
||||||
|
|
@ -720,8 +720,6 @@ def handover_submit(handover:Handover, user: User, now: Union[datetime.datetime,
|
||||||
recive_mgroup = handover.recive_mgroup
|
recive_mgroup = handover.recive_mgroup
|
||||||
recive_dept = handover.recive_dept
|
recive_dept = handover.recive_dept
|
||||||
|
|
||||||
if handover.type == Handover.H_CHANGE:
|
|
||||||
handover.mtype = Handover.H_MERGE
|
|
||||||
new_batch = handover.new_batch
|
new_batch = handover.new_batch
|
||||||
if new_batch and mtype != Handover.H_MERGE:
|
if new_batch and mtype != Handover.H_MERGE:
|
||||||
raise ParseError("只有合并时才能提供新批次号")
|
raise ParseError("只有合并时才能提供新批次号")
|
||||||
|
|
|
||||||
|
|
@ -524,7 +524,7 @@ class HandoverViewSet(CustomModelViewSet):
|
||||||
queryset = Handover.objects.all()
|
queryset = Handover.objects.all()
|
||||||
list_serializer_class = HandoverListSerializer
|
list_serializer_class = HandoverListSerializer
|
||||||
serializer_class = HandoverSerializer
|
serializer_class = HandoverSerializer
|
||||||
select_related_fields = ["send_user", "send_mgroup", "send_dept", "recive_user", "recive_mgroup", "recive_dept", "wm"]
|
select_related_fields = ["send_user", "send_mgroup", "send_dept", "recive_user", "recive_mgroup", "recive_dept", "wm", "material_changed", "material"]
|
||||||
filterset_class = HandoverFilter
|
filterset_class = HandoverFilter
|
||||||
search_fields = ["id", "material__name", "material__number", "material__specification", "batch", "material__model", "b_handover__batch", "new_batch", "wm__batch"]
|
search_fields = ["id", "material__name", "material__number", "material__specification", "batch", "material__model", "b_handover__batch", "new_batch", "wm__batch"]
|
||||||
prefetch_related_fields = [Prefetch("b_handover", queryset=Handoverb.objects.select_related("wm__defect"))]
|
prefetch_related_fields = [Prefetch("b_handover", queryset=Handoverb.objects.select_related("wm__defect"))]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue