feat: mlogb增加count_json
This commit is contained in:
parent
c44b71b847
commit
f7e3e7977d
|
@ -645,12 +645,24 @@ class MlogChangeSerializer(CustomModelSerializer):
|
|||
return attrs
|
||||
|
||||
|
||||
class CountJsonSerializer(serializers.Serializer):
|
||||
count_use = serializers.IntegerField(min_value=0, required=True)
|
||||
floor = serializers.IntegerField(min_value=1, required=True)
|
||||
|
||||
class CountJson2Serializer(serializers.Serializer):
|
||||
count_use = serializers.IntegerField(min_value=0, required=True)
|
||||
floor = serializers.IntegerField(min_value=1, required=True)
|
||||
count_test = serializers.IntegerField(min_value=0, required=True)
|
||||
count_notok = serializers.IntegerField(min_value=0, required=True)
|
||||
|
||||
class MlogbInSerializer(CustomModelSerializer):
|
||||
mlogbdefect = MlogbDefectSerializer(many=True, required=False)
|
||||
count_json = CountJsonSerializer(required=False, many=True)
|
||||
|
||||
class Meta:
|
||||
model = Mlogb
|
||||
fields = ['id', 'mlog', 'mtask', 'wm_in', 'count_use', 'count_pn_jgqbl',
|
||||
'count_break', 'note', "parent", "mlogbdefect"]
|
||||
'count_break', 'note', "parent", "mlogbdefect", "count_json"]
|
||||
extra_kwargs = {'count_use': {'required': True}, 'mtask': {'required': False},
|
||||
'wm_in': {'required': True, "allow_empty": False}}
|
||||
|
||||
|
@ -793,12 +805,13 @@ class MlogbwCreateUpdateSerializer(CustomModelSerializer):
|
|||
|
||||
class MlogbOutUpdateSerializer(CustomModelSerializer):
|
||||
mlogbdefect = MlogbDefectSerializer(many=True, required=False)
|
||||
count_json = CountJson2Serializer(required=False, many=True)
|
||||
|
||||
class Meta:
|
||||
model = Mlogb
|
||||
fields = "__all__"
|
||||
read_only_fields = EXCLUDE_FIELDS_BASE + ['mlog', 'mtask', 'wm_in', 'material_in', 'material_out',
|
||||
'count_use', 'count_break', 'count_pn_jgqbl', 'mlogbdefect', "qct", "batch"]
|
||||
'count_use', 'count_break', 'count_pn_jgqbl', 'mlogbdefect', "qct", "batch", "count_json"]
|
||||
|
||||
# def create(self, validated_data):
|
||||
# material_out:Material = validated_data["material_out"]
|
||||
|
|
|
@ -588,6 +588,8 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
|
|||
d_count_ok = mlogbin.count_use
|
||||
mlogbout, _ = Mlogb.objects.get_or_create(mlogb_from=mlogbin, defaults=
|
||||
update_dict(m_dict, {"count_real": d_count_real, "count_ok": d_count_ok}))
|
||||
mlogbout.count_json = mlogbin.count_json
|
||||
mlogbout.save(update_fields=["count_json"])
|
||||
if material_in.tracking == Material.MA_TRACKING_SINGLE and material_out.tracking == Material.MA_TRACKING_SINGLE:
|
||||
for mlogbwin in Mlogbw.objects.filter(mlogb=mlogbin).order_by("number"):
|
||||
wpr_ = mlogbwin.wpr
|
||||
|
@ -610,12 +612,16 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
|
|||
elif material_in.tracking == Material.MA_TRACKING_BATCH and material_out.tracking == Material.MA_TRACKING_BATCH:
|
||||
d_count_real = mlogbin.count_use * div_number
|
||||
d_count_ok = d_count_real
|
||||
Mlogb.objects.get_or_create(mlogb_from=mlogbin, defaults=update_dict(m_dict,{"count_real": d_count_real, "count_ok": d_count_ok}))
|
||||
mlogbout, _ = Mlogb.objects.get_or_create(mlogb_from=mlogbin, defaults=update_dict(m_dict,{"count_real": d_count_real, "count_ok": d_count_ok}))
|
||||
mlogbout.count_json = mlogbin.count_json
|
||||
mlogbout.save(update_fields=["count_json"])
|
||||
elif mtype == Process.PRO_MERGE: # 支持批到批
|
||||
xcount = math.floor( mlogbin.count_use / route.div_number)
|
||||
d_count_real = xcount
|
||||
d_count_ok = xcount
|
||||
Mlogb.objects.get_or_create(mlogb_from=mlogbin, defaults=update_dict(m_dict, {"count_real": d_count_real, "count_ok": d_count_ok}))
|
||||
mlogbout, _ = Mlogb.objects.get_or_create(mlogb_from=mlogbin, defaults=update_dict(m_dict, {"count_real": d_count_real, "count_ok": d_count_ok}))
|
||||
mlogbout.count_json = mlogbin.count_json
|
||||
mlogbout.save(update_fields=["count_json"])
|
||||
elif is_fix:# 支持批到批,个到个
|
||||
d_count_real = mlogbin.count_use
|
||||
d_count_ok = mlogbin.count_use
|
||||
|
|
Loading…
Reference in New Issue