feat: route添加parent字段以支持子步骤

This commit is contained in:
caoqianming 2025-02-19 14:02:29 +08:00
parent f741eda285
commit 5f0d34f9c3
3 changed files with 30 additions and 7 deletions

View File

@ -0,0 +1,19 @@
# Generated by Django 3.2.12 on 2025-02-19 05:55
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('mtm', '0050_auto_20250207_1002'),
]
operations = [
migrations.AddField(
model_name='route',
name='parent',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='mtm.route', verbose_name='上级路线'),
),
]

View File

@ -237,6 +237,7 @@ class Route(CommonADModel):
batch_bind = models.BooleanField('是否绑定批次', default=True)
materials = models.ManyToManyField(Material, verbose_name='关联辅助物料', related_name="route_materials",
through="mtm.routemat", blank=True)
parent = models.ForeignKey('self', verbose_name='上级路线', on_delete=models.CASCADE, null=True, blank=True)
@staticmethod
def get_routes(material: Material):

View File

@ -26,12 +26,15 @@ class PmService:
if indx + 1 == rate_len: # 循环到最后一步
break
div_number0 = 1
rate, div_number, mtype = rate_list[indx+1]
if mtype == Process.PRO_DIV:
div_number0 = div_number
elif mtype == Process.PRO_MERGE:
div_number0 = 1/div_number
xcount = xcount/(rate/100)/div_number0
rate, div_number, mtype, rq = rate_list[indx+1]
if rq.parent is None:
xcount = 0
else:
if mtype == Process.PRO_DIV:
div_number0 = div_number
elif mtype == Process.PRO_MERGE:
div_number0 = 1/div_number
xcount = xcount/(rate/100)/div_number0
indx = indx + 1
r_list.append(math.ceil(xcount))
return r_list
@ -136,7 +139,7 @@ class PmService:
if not rqs.exists():
raise ParseError('未配置工艺路线')
# 通过出材率校正任务数, out_rate 默认为 100
out_rate_list = [(rq.out_rate, rq.div_number, rq.process.mtype) for rq in rqs]
out_rate_list = [(rq.out_rate, rq.div_number, rq.process.mtype, rq) for rq in rqs]
count_task_list = cls.cal_real_task_count(count,out_rate_list)
# 创建小任务
for ind, val in enumerate(rqs):