factory/apps/pm/models.py

39 lines
1.6 KiB
Python

from django.db import models
from apps.utils.models import CommonADModel
from apps.mtm.models import Material, Mgroup
# Create your models here.
class Mtask(CommonADModel):
"""
生产任务
"""
MTASK_CREATED = 10
MTASK_ASSGINED = 20
MTASK_WORKING = 30
MTASK_DONE = 40
MTASK_STATES = (
(MTASK_CREATED, '创建中'),
(MTASK_ASSGINED, '已下达'),
# (MTASK_WORKING, '生产中'),
# (MTASK_DONE, '已结束')
)
state = models.PositiveIntegerField(
'状态', choices=MTASK_STATES, default=MTASK_CREATED, help_text=str(MTASK_STATES))
number = models.CharField('编号', max_length=50, unique=True)
mgroup = models.ForeignKey(
Mgroup, verbose_name='工段', on_delete=models.CASCADE)
material_before = models.ForeignKey(
Material, verbose_name='领用物', on_delete=models.CASCADE, related_name='mtask_material_before', null=True, blank=True)
material = models.ForeignKey(
Material, verbose_name='产物', on_delete=models.CASCADE, related_name='mtask_material')
count = models.PositiveIntegerField('任务数', default=1)
count_real = models.PositiveIntegerField('实际生产数', default=0)
count_ok = models.PositiveIntegerField('合格数', default=0)
count_notok = models.PositiveIntegerField('不合格数', default=0)
start_date = models.DateField('计划开工日期')
end_date = models.DateField('计划完工日期')
parent = models.ForeignKey(
'self', null=True, blank=True, on_delete=models.SET_NULL, verbose_name='父任务')