52 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			Python
		
	
	
	
			
		
		
	
	
			52 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			Python
		
	
	
	
| from django.db import models
 | |
| from django.db.models.base import Model
 | |
| import django.utils.timezone as timezone
 | |
| from django.db.models.query import QuerySet
 | |
| from apps.pm.models import ProductionPlan, SubProductionPlan
 | |
| from apps.system.models import CommonAModel, CommonBModel, Organization, User, Dict, File
 | |
| from utils.model import SoftModel, BaseModel
 | |
| from simple_history.models import HistoricalRecords
 | |
| from apps.mtm.models import Material, Process, Step, RecordForm
 | |
| 
 | |
| class WMaterial(BaseModel):
 | |
|     """
 | |
|     车间生产物料
 | |
|     """
 | |
|     # workshop = models.ForeignKey(Organization, verbose_name='生产车间', on_delete=models.CASCADE)
 | |
|     # process = models.ForeignKey(Process, verbose_name='关联大工序', on_delete=models.CASCADE)
 | |
|     subproduction_plan = models.ForeignKey(SubProductionPlan, verbose_name='关联子计划', on_delete=models.CASCADE)
 | |
|     material = models.ForeignKey(Material, verbose_name='关联物料', on_delete=models.CASCADE)
 | |
|     batch = models.CharField('批次号', max_length=100, null=True, blank=True)
 | |
|     count = models.IntegerField('当前数量', default=0)
 | |
| 
 | |
| class WProduct(CommonAModel):
 | |
|     """
 | |
|     半成品/成品
 | |
|     """
 | |
|     act_state_choices=(
 | |
|         (0, '待执行'),
 | |
|         (1, '进行中'),
 | |
|         (2, '已完成')
 | |
|     )
 | |
|     number = models.CharField('物品编号', unique=True, null=True, blank=True, max_length=50)
 | |
|     m_state = models.ForeignKey(Material, verbose_name='所属物料状态', on_delete=models.CASCADE)
 | |
|     p_state = models.ForeignKey(Step, verbose_name='所在步骤', on_delete=models.CASCADE, null=True, blank=True)
 | |
|     act_state = models.IntegerField('进行状态', default=0)
 | |
|     parent = models.ForeignKey('self', verbose_name='上一级', on_delete=models.CASCADE, db_constraint=False)
 | |
|     remark = models.CharField('备注', max_length=200, null=True, blank=True)
 | |
|     subproduction_plan = models.ForeignKey(SubProductionPlan, verbose_name='当前子生产计划', on_delete=models.CASCADE)
 | |
|     production_plan = models.ForeignKey(ProductionPlan, verbose_name='关联主生产计划', on_delete=models.CASCADE)
 | |
| 
 | |
| class WProductRecord(CommonAModel):
 | |
|     """
 | |
|     记录表格
 | |
|     """
 | |
|     record_form = models.ForeignKey(RecordForm, verbose_name='所用表格', on_delete=models.CASCADE)
 | |
|     data = models.JSONField('记录的数据', default=dict, blank=True)
 | |
| 
 | |
| 
 | |
| class WProductFlow(BaseModel):
 | |
|     """
 | |
|     生产操作日志
 | |
|     """
 | |
|     wproducts = models.JSONField('关联产品', default=list) |