o
    >:h                     @   s   d dl mZ d dlmZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ e	 ZG d	d
 d
ejZG dd dejZG dd dejZG dd dejZG dd dejZdS )    )models)EmpaqueProduccion)
Referencia)ListaMateriales)get_user_model)ValidationError)timezone)	timedeltac                   @   st   e Zd ZejddddZejddZejdddZejd	d
dZ	ej
ddZejdddZG dd dZdd ZdS )PlantaProducciond   TzNombre de planta)
max_lengthuniqueverbose_nameu
   Direcciónr   u   Contacto producciónr   r      u   Teléfono contactozEmail contactoActivodefaultr   c                   @      e Zd ZdZdZdgZdS )zPlantaProduccion.Metau   Planta de Producciónu   Plantas de ProducciónnombreN__name__
__module____qualname__r   verbose_name_pluralordering r   r   */var/www/html/public/fabricacion/models.pyMeta       
r   c                 C   s   | j S N)r   selfr   r   r   __str__   s   zPlantaProduccion.__str__N)r   r   r   r   	CharFieldr   	TextField	direccioncontacto_producciontelefono_contacto
EmailFieldemail_contactoBooleanFieldactivor   r$   r   r   r   r   r
      s    r
   c                   @   sh   e Zd ZejeejddZejdddZ	ej
ddZej
ddZejd	d
dZG dd dZdd ZdS )Maquinamaquinas	on_deleterelated_namer   u   Nombre de máquinar   z#Tiempo para poner operativa (horas)r   u%   Período entre mantenimientos (días)TActivar   c                   @   s    e Zd ZdZdZddgZdZdS )zMaquina.Metau   Máquinau	   Máquinasplantar   r4   r   N)r   r   r   r   r   r   unique_togetherr   r   r   r   r   -   s
    r   c                 C   s   | j  d| j S )N - r5   r"   r   r   r   r$   3   s   zMaquina.__str__N)r   r   r   r   
ForeignKeyr
   CASCADEr4   r%   r   PositiveIntegerFieldtiempo_configuracionperiodo_mantenimientor,   activar   r$   r   r   r   r   r.      s     r.   c                       s   e Zd ZejeejddZejeejddZ	ej
ddZej
ddZej
ddd	Zej
d
dZejeejddZej
ddZejddddZG dd dZ fddZdd Zdd Z  ZS )MaquinaReferenciareferencias_maquinar0   maquinas_referenciaz!Lead time generar orden (Minutos)r   u   Lead time producción (Minutos)zLead time total (Minutos)F)r   editableu   Mínimo unidades por loteu   Empaque de producción)r1   r   zUnidades por empaque
      zUnidades producidas por minuto)
max_digitsdecimal_placesr   c                   @   s   e Zd ZdZdZdZdS )zMaquinaReferencia.Metau   Relación Máquina-Referenciau   Relaciones Máquina-Referencia)maquina
referenciaN)r   r   r   r   r   r6   r   r   r   r   r   ^   s    r   c                    s$   | j | j | _t j|i | d S r!   )lead_time_generar_ordenlead_time_produccionlead_time_totalsupersave)r#   argskwargs	__class__r   r   rL   c   s   zMaquinaReferencia.savec                 C   s   | j  d| j d| j dS )Nu    → z (Velocidad: z/min))rF   rG   unidades_por_minutor"   r   r   r   r$   g   s   zMaquinaReferencia.__str__c                 C   s   | j dkrdS t|| j  dS )zR
        Calcula el tiempo estimado para producir X unidades (en minutos)
        r   rC   )rQ   round)r#   cantidadr   r   r   tiempo_estimado_produccionk   s   
z,MaquinaReferencia.tiempo_estimado_produccion)r   r   r   r   r8   r.   r9   rF   r   rG   r:   rH   rI   rJ   minimo_unidadesr   PROTECTempaqueunidades_por_empaqueDecimalFieldrQ   r   rL   r$   rT   __classcell__r   r   rO   r   r>   7   sR    r>   c                   @   sv   e Zd ZejeejddZejddZ	ej
ddZejddZejddd	Zejd
d
ddZG dd dZdd ZdS )Mantenimientomantenimientosr0   zConcepto del mantenimientor   zTiempo estimado (horas)zFecha programadaF	Realizador   Tu   Fecha de realización)nullblankr   c                   @   r   )zMantenimiento.Metar[   Mantenimientosfecha_programadaNr   r   r   r   r   r      r    r   c                 C      d| j  d| j S )NzMantenimiento r7   )rF   ra   r"   r   r   r   r$         zMantenimiento.__str__N)r   r   r   r   r8   r.   r9   rF   r&   conceptor:   tiempo_mantenimiento	DateFieldra   r,   	realizadofecha_realizacionr   r$   r   r   r   r   r[   s   s&    r[   c                   @   sf   e Zd ZejeejddZejddZ	ej
ddZejddZejddd	ZG d
d dZdd ZdS )
Reparacionreparacionesr0   u   Concepto de la reparaciónr   zTiempo empleado (horas)u   Fecha de reparaciónTzObservaciones adicionales)r_   r   c                   @   r   )zReparacion.Metau   ReparaciónReparacionesz-fecha_reparacionNr   r   r   r   r   r      r    r   c                 C   rb   )Nu   Reparación r7   )rF   fecha_reparacionr"   r   r   r   r$      rc   zReparacion.__str__N)r   r   r   r   r8   r.   r9   rF   r&   rd   r:   tiempo_arreglorf   rl   observacionesr   r$   r   r   r   r   ri      s    ri   N)	django.dbr   listas_configuracion.modelsr   referencias.modelsr   lista_de_materiales.modelsr   django.contrib.authr   django.core.exceptionsr   django.utilsr   datetimer	   UserModelr
   r.   r>   r[   ri   r   r   r   r   <module>   s   <