fix: mlog 数值计算bug
This commit is contained in:
parent
dbad152218
commit
c02bb6d3db
|
@ -316,7 +316,7 @@ class Mlog(CommonADModel):
|
||||||
通过mlogb计算mlog count 合计
|
通过mlogb计算mlog count 合计
|
||||||
"""
|
"""
|
||||||
mlog = self
|
mlog = self
|
||||||
if mlog.fill_way == Mlog.MLOG_23:
|
if mlog.fill_way in [Mlog.MLOG_23, Mlog.MLOG_12]:
|
||||||
a_dict = {
|
a_dict = {
|
||||||
"total_count_use": Sum('count_use'),
|
"total_count_use": Sum('count_use'),
|
||||||
"total_count_break": Sum('count_break'),
|
"total_count_break": Sum('count_break'),
|
||||||
|
|
|
@ -579,20 +579,21 @@ class MlogSerializer(CustomModelSerializer):
|
||||||
supplier = attrs.get('supplier', None)
|
supplier = attrs.get('supplier', None)
|
||||||
if not supplier:
|
if not supplier:
|
||||||
raise ParseError('外协必须选择外协单位')
|
raise ParseError('外协必须选择外协单位')
|
||||||
|
|
||||||
mtask = attrs.get('mtask', None)
|
mtask = attrs.get('mtask', None)
|
||||||
count_notok = 0
|
mlogdefect = attrs.get('mlogdefect', None)
|
||||||
for i in attrs:
|
if mlogdefect is None:
|
||||||
if 'count_n_' in i:
|
count_notok = 0
|
||||||
if attrs[i] < 0:
|
for i in attrs:
|
||||||
raise ParseError(f'{attrs[i]}不能小于0')
|
if 'count_n_' in i:
|
||||||
count_notok = count_notok + attrs[i]
|
if attrs[i] < 0:
|
||||||
attrs['count_notok'] = count_notok
|
raise ParseError(f'{attrs[i]}不能小于0')
|
||||||
|
count_notok = count_notok + attrs[i]
|
||||||
|
attrs['count_notok'] = count_notok
|
||||||
if attrs['count_ok'] < 0:
|
if attrs['count_ok'] < 0:
|
||||||
raise ParseError('合格数量不能小于0')
|
raise ParseError('合格数量不能小于0')
|
||||||
if attrs['count_real'] >= attrs['count_ok'] + attrs['count_notok']:
|
if attrs['count_real'] != attrs['count_ok'] + attrs['count_notok']:
|
||||||
pass
|
raise ParseError('生产数量需等于合格数量+不合格数量')
|
||||||
else:
|
|
||||||
raise ParseError('生产数量不能小于合格数量')
|
|
||||||
if mtask:
|
if mtask:
|
||||||
if mtask.start_date == mtask.end_date:
|
if mtask.start_date == mtask.end_date:
|
||||||
attrs['handle_date'] = mtask.start_date
|
attrs['handle_date'] = mtask.start_date
|
||||||
|
|
Loading…
Reference in New Issue