feat: 单工序多工段情况下平均分配
This commit is contained in:
parent
32158dfa77
commit
72b04ddc7a
|
@ -147,12 +147,15 @@ class PmService:
|
||||||
mgroups = Mgroup.objects.filter(process=val.process)
|
mgroups = Mgroup.objects.filter(process=val.process)
|
||||||
mgroups_count = mgroups.count()
|
mgroups_count = mgroups.count()
|
||||||
if mgroups_count == 1:
|
if mgroups_count == 1:
|
||||||
mgroup = mgroups.first()
|
pass
|
||||||
elif mgroups_count == 0:
|
elif mgroups_count == 0:
|
||||||
raise ParseError(f'第{ind+1}步-工段不存在!')
|
raise ParseError(f'第{ind+1}步-工段不存在!')
|
||||||
else: # 后面可能会指定车间
|
else: # 存在同一工序的多个工段,先平均分配
|
||||||
raise ParseError(f'第{ind+1}步-工段存在多个!')
|
pass
|
||||||
if schedule_type == 'to_day':
|
if schedule_type == 'to_day':
|
||||||
|
if mgroups_count > 1:
|
||||||
|
raise ParseError(f'第{ind+1}步-工段存在多个!')
|
||||||
|
mgroup = mgroups.first()
|
||||||
task_count_day = math.ceil(count_task_list[ind]/rela_days)
|
task_count_day = math.ceil(count_task_list[ind]/rela_days)
|
||||||
if rela_days >= 1:
|
if rela_days >= 1:
|
||||||
for i in range(rela_days):
|
for i in range(rela_days):
|
||||||
|
@ -173,22 +176,23 @@ class PmService:
|
||||||
'is_count_utask': val.is_count_utask
|
'is_count_utask': val.is_count_utask
|
||||||
})
|
})
|
||||||
elif schedule_type == 'to_mgroup':
|
elif schedule_type == 'to_mgroup':
|
||||||
Mtask.objects.create(**{
|
for indx, mgroup in enumerate(mgroups):
|
||||||
'route': val,
|
Mtask.objects.create(**{
|
||||||
'number': f'{number}_r{ind+1}',
|
'route': val,
|
||||||
'type': utask.type,
|
'number': f'{number}_r{ind+1}_m{indx+1}',
|
||||||
'material_out': halfgood,
|
'type': utask.type,
|
||||||
'material_in': material_in,
|
'material_out': halfgood,
|
||||||
'mgroup': mgroup,
|
'material_in': material_in,
|
||||||
'count': count_task_list[ind],
|
'mgroup': mgroup,
|
||||||
'start_date': start_date,
|
'count': math.ceil(count_task_list[ind]/mgroups_count),
|
||||||
'end_date': end_date,
|
'start_date': start_date,
|
||||||
'utask': utask,
|
'end_date': end_date,
|
||||||
'create_by': user,
|
'utask': utask,
|
||||||
'update_by': user,
|
'create_by': user,
|
||||||
'hour_work': val.hour_work,
|
'update_by': user,
|
||||||
'is_count_utask': val.is_count_utask
|
'hour_work': val.hour_work,
|
||||||
})
|
'is_count_utask': val.is_count_utask
|
||||||
|
})
|
||||||
else:
|
else:
|
||||||
raise ParseError('不支持的排产类型')
|
raise ParseError('不支持的排产类型')
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
Loading…
Reference in New Issue