feat: count_n_jgqbl 改为count_pn_jgqbl
This commit is contained in:
parent
eb5a8df7e0
commit
982247ee70
|
@ -12,12 +12,12 @@ class Migration(migrations.Migration):
|
|||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='mlog',
|
||||
name='count_n_jgqbl',
|
||||
name='count_pn_jgqbl',
|
||||
field=models.PositiveIntegerField(default=0, verbose_name='加工前不良'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='mlogb',
|
||||
name='count_n_jgqbl',
|
||||
name='count_pn_jgqbl',
|
||||
field=models.PositiveIntegerField(default=0, verbose_name='加工前不良'),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -164,7 +164,7 @@ class Mlog(CommonADModel):
|
|||
count_notok = models.PositiveIntegerField('不合格数', default=0)
|
||||
count_break_t = models.PositiveIntegerField('检验碎料数', default=0)
|
||||
|
||||
count_n_jgqbl = models.PositiveIntegerField('加工前不良', default=0)
|
||||
count_pn_jgqbl = models.PositiveIntegerField('加工前不良', default=0)
|
||||
count_n_zw = models.PositiveIntegerField('炸纹', default=0)
|
||||
count_n_tw = models.PositiveIntegerField('条纹', default=0)
|
||||
count_n_qp = models.PositiveIntegerField('气泡', default=0)
|
||||
|
@ -263,7 +263,7 @@ class Mlogb(BaseModel):
|
|||
count_ok = models.PositiveIntegerField('合格数量', default=0)
|
||||
count_notok = models.PositiveIntegerField('不合格数', default=0)
|
||||
|
||||
count_n_jgqbl = models.PositiveIntegerField('加工前不良', default=0)
|
||||
count_pn_jgqbl = models.PositiveIntegerField('加工前不良', default=0)
|
||||
# 添加不合格字段后需要更改cal_mlog_count_from_mlogb
|
||||
count_n_hs = models.PositiveIntegerField('划伤', default=0)
|
||||
count_n_qp = models.PositiveIntegerField('气泡', default=0)
|
||||
|
@ -288,7 +288,8 @@ class Handover(CommonADModel):
|
|||
H_NORMAL = 10
|
||||
H_REPAIR = 20
|
||||
H_TEST = 30
|
||||
type = models.PositiveSmallIntegerField('交接类型', choices=[(H_NORMAL, '正常交接'), (H_REPAIR, '返修交接'), (H_TEST, '检验交接')], default=H_NORMAL)
|
||||
H_SCRAP = 40
|
||||
type = models.PositiveSmallIntegerField('交接类型', choices=[(H_NORMAL, '正常交接'), (H_REPAIR, '返修交接'), (H_TEST, '检验交接'), (H_SCRAP, '报废交接')], default=H_NORMAL)
|
||||
send_date = models.DateField('送料日期')
|
||||
send_user = models.ForeignKey(
|
||||
User, verbose_name='交送人', on_delete=models.CASCADE, related_name='handover_send_user')
|
||||
|
@ -318,6 +319,8 @@ class Handover(CommonADModel):
|
|||
submit_user = models.ForeignKey(
|
||||
User, verbose_name='提交人', on_delete=models.CASCADE, null=True, blank=True, related_name='handover_submit_user')
|
||||
|
||||
class Handoverb(BaseModel):
|
||||
pass
|
||||
|
||||
class AttLog(CommonADModel):
|
||||
"""
|
||||
|
|
|
@ -305,7 +305,7 @@ class MlogSerializer(CustomModelSerializer):
|
|||
'mlog': instance, 'batch': batch_in, 'wm_in': instance.wm_in,
|
||||
'mtask': instance.mtask, 'material_in': instance.material_in,
|
||||
'count_use': instance.count_use, 'count_break': instance.count_break,
|
||||
'count_n_jgqbl': instance.count_n_jgqbl
|
||||
'count_pn_jgqbl': instance.count_pn_jgqbl
|
||||
}
|
||||
Mlogb.objects.create(**add_dict)
|
||||
|
||||
|
@ -334,7 +334,7 @@ class MlogSerializer(CustomModelSerializer):
|
|||
'count_break_t': instance.count_break_t
|
||||
}
|
||||
for f in Mlogb._meta.fields:
|
||||
if 'count_n_' in f.name and f.name != 'count_n_jgqbl':
|
||||
if 'count_n_' in f.name and f.name != 'count_pn_jgqbl':
|
||||
add_dict_2[f.name] = getattr(instance, f.name)
|
||||
Mlogb.objects.create(**add_dict_2)
|
||||
return instance
|
||||
|
@ -440,7 +440,7 @@ class MlogChangeSerializer(CustomModelSerializer):
|
|||
class MlogbInSerializer(CustomModelSerializer):
|
||||
class Meta:
|
||||
model = Mlogb
|
||||
fields = ['id', 'mlog', 'mtask', 'wm_in', 'count_use', 'count_n_jgqbl', 'count_break', 'note']
|
||||
fields = ['id', 'mlog', 'mtask', 'wm_in', 'count_use', 'count_pn_jgqbl', 'count_break', 'note']
|
||||
extra_kwargs = {'count_use': {'required': True}, 'mtask': {'required': True}, 'wm_in': {'required': True}}
|
||||
|
||||
def validate(self, attrs):
|
||||
|
@ -480,13 +480,13 @@ class MlogbInSerializer(CustomModelSerializer):
|
|||
class MlogbInUpdateSerializer(CustomModelSerializer):
|
||||
class Meta:
|
||||
model = Mlogb
|
||||
fields = ['id', 'count_use', 'count_break', 'count_n_jgqbl', 'note']
|
||||
fields = ['id', 'count_use', 'count_break', 'count_pn_jgqbl', 'note']
|
||||
|
||||
class MlogbOutUpdateSerializer(CustomModelSerializer):
|
||||
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_n_jgqbl']
|
||||
read_only_fields = EXCLUDE_FIELDS_BASE + ['mlog', 'mtask', 'wm_in', 'material_in', 'material_out', 'count_use', 'count_break', 'count_pn_jgqbl']
|
||||
|
||||
def validate(self, attrs):
|
||||
count_notok_json = attrs.get('count_notok_json', [])
|
||||
|
|
|
@ -227,8 +227,8 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
m_ins_bl_list = []
|
||||
for mi in m_ins.all():
|
||||
m_ins_list.append((mi.material_in, mi.batch, mi.count_use, mi.wm_in))
|
||||
if mi.count_n_jgqbl > 0:
|
||||
m_ins_bl_list.append((mi.material_in, mi.batch, mi.count_n_jgqbl))
|
||||
if mi.count_pn_jgqbl > 0:
|
||||
m_ins_bl_list.append((mi.material_in, mi.batch, mi.count_pn_jgqbl))
|
||||
else:
|
||||
m_ins_list = [(material_in, mlog.batch, mlog.count_use, mlog.wm_in)]
|
||||
for mi in m_ins_list:
|
||||
|
@ -261,11 +261,11 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
wm.save()
|
||||
# 针对加工前不良的暂时额外处理
|
||||
for item in m_ins_bl_list:
|
||||
material, batch, count_n_jgqbl = item
|
||||
if count_n_jgqbl> 0:
|
||||
material, batch, count_pn_jgqbl = item
|
||||
if count_pn_jgqbl> 0:
|
||||
lookup = {'batch': batch, 'material': material, 'mgroup': mgroup, 'notok_sign': 'jgqbl', 'state': WMaterial.WM_NOTOK}
|
||||
wm, is_create = WMaterial.objects.get_or_create(**lookup, defaults={**lookup, "belong_dept": belong_dept})
|
||||
wm.count = wm.count + item.count_n_jgqbl
|
||||
wm.count = wm.count + item.count_pn_jgqbl
|
||||
if is_create:
|
||||
wm.create_by = user
|
||||
else:
|
||||
|
@ -340,8 +340,8 @@ def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
m_ins_bl_list = []
|
||||
for mi in m_ins.all():
|
||||
m_ins_list.append((mi.material_in, mi.batch, mi.count_use, mi.wm_in))
|
||||
if mi.count_n_jgqbl > 0:
|
||||
m_ins_bl_list.append((mi.material_in, mi.batch, mi.count_n_jgqbl))
|
||||
if mi.count_pn_jgqbl > 0:
|
||||
m_ins_bl_list.append((mi.material_in, mi.batch, mi.count_pn_jgqbl))
|
||||
else:
|
||||
m_ins_list = [(material_in, mlog.batch, mlog.count_use, mlog.wm_in)]
|
||||
for mi in m_ins_list:
|
||||
|
@ -365,11 +365,11 @@ def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
wm.save()
|
||||
# 针对加工前不良的暂时额外处理
|
||||
for item in m_ins_bl_list:
|
||||
material, batch, count_n_jgqbl = item
|
||||
if count_n_jgqbl> 0:
|
||||
material, batch, count_pn_jgqbl = item
|
||||
if count_pn_jgqbl> 0:
|
||||
lookup = {'batch': batch, 'material': material, 'mgroup': mgroup, 'notok_sign': 'jgqbl', 'state': WMaterial.WM_NOTOK}
|
||||
wm, is_create = WMaterial.objects.get_or_create(**lookup, defaults={**lookup, "belong_dept": belong_dept})
|
||||
wm.count = wm.count - item.count_n_jgqbl
|
||||
wm.count = wm.count - item.count_pn_jgqbl
|
||||
if wm.count < 0:
|
||||
raise ParseError('加工前不良数量大于库存量')
|
||||
if is_create:
|
||||
|
@ -639,6 +639,8 @@ def handover_submit(handover: Handover, user: User, now: Union[datetime.datetime
|
|||
state=WMaterial.WM_TEST,
|
||||
defaults={"batch": batch, "material": material, "belong_dept": handover.recive_dept, "count_xtest": 0, "state": WMaterial.WM_TEST},
|
||||
)
|
||||
elif handover.type == Handover.H_SCRAP:
|
||||
raise ParseError("不支持交接类型")
|
||||
else:
|
||||
raise ParseError("不支持交接类型")
|
||||
|
||||
|
|
Loading…
Reference in New Issue