
    L[e^                     t    d dl mZ d dl mZ d dlmZ d dlZd dlZd dlZd dl	Z
d Zd Zd Zd Zd	 Zd
 Zd ZdS )    render)redirect)JsonResponseNc                 "    t          | d          S )Nzreporting/reporting.htmlr   requests    MC:\Users\Lenovo\Downloads\rfid_django_1\rfid_django_1\core\reporting\views.pyget_reportingr   
   s    '4555    c                     t          j        d          }t          |           t          |                                          S )Nz<https://thingsaccess.com/rfid/index.php/Api/qualityReporting)requestsgetprintr   json)r	   responses     r
   reporting_resultr      s3    |Z[[H	(OOO(((r   c                 "    t          | d          S )Nz%reporting/fitlerArticleReporting.htmlr   r   s    r
   filterArticleReportingr      s    'ABBBr   c                 T   t          j        | j                  }t          | j        d                    t          j        | j        d         d          }t          j        |          }|                    d          }t          j	                    }|d         D ]6}||d         |k             }t          j
        |||d                  g          }7|                    d	
          }t          j        |d          }t          t          |                     t          d|i          S )Narticleinfo   indentTdroparticleColumnarticle_namearticleDatarecordsorientget_data)r   loadsbodyr   sessiondumpspd	read_jsonreset_index	DataFrameconcatto_dicttyper   )	r	   datajson_article_infor)   filtered_resultsarticlesfilter_jsonr#   	json_datas	            r
   filterArticleDatar5      s   :gl##D	'/-
()))
7?=#AKKK.//I%%4%00I|~~) Z Z	. 98 CD9&6{4CV7W%XYY''y'99H
81---I	$x..H-...r   c                    t          j        | j                  }t          t	          | j        d                              g }t          t          | j        d                             D ]}|                    | j        d         |         d         d         | j        d         |         d         d         | j        d         |         d         d         | j        d         |         d         d         | j        d         |         d         d         | j        d         |         d         d         | j        d         |         d         d	         | j        d         |         d         d
         | j        d         |         d         d         | j        d         |         d         d         | j        d         |         d         d         | j        d         |         d         d         d           t          j	        |d          }t          j        |          }|                    d          }t          j                    }|d                             t                    |d<   |d         D ]U}||d         |k             }t          d|           t          j        |||d                  g          }t          |           V|                    d          }	t          |	           |	D ]J}
|
                                D ]3\  }}t'          |t(                    rt+          j        |          rd |
|<   4Kt          j	        |	d          }t          |           t/          d|	i          S )NoperatorsInfooperator_dataidnamecniccelladdressskillstag_idtiming	status_idstatuswage
created_on)r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   r   r   Tr   r   r3   r   r    r!   r#   )r   r$   r%   r   r.   r&   rangelenappendr'   r(   r)   r*   r+   astypestrr,   r-   items
isinstancefloatnpisnanr   )r	   r/   operator_jsonir0   r)   r1   r2   r3   r#   itemkeyvaluer4   s                 r
   filterOperatorDatarT   '   s8   :gl##D	$w/
0
0111M3w78899 ! !7??#CA#F#WX\#]%,__%Ea%H%YZ`%a%,__%Ea%H%YZ`%a%,__%Ea%H%YZ`%a(/(H(KO(\]f(g'.'G'J?'[\d'e'.'G'J?'[\d'e'.'G'J?'[\d'e*1//*J1*Mo*^_j*k'.'G'J?'[\d'e%,__%Ea%H%YZ`%a+2??+KA+N+_`l+m    	! 	! 	! 	! 
=:::.//I%%4%00I|~~o,,S11IdO)    	$ 9:mK(((9&6{4CV7W%XYY''y'99H	(OOO ! !**,, 	! 	!JC%'' !BHUOO ! S		! 
8A...I	)H-...r   c                 2   t          |            | j        dk    rt          j        | j                  }|                    d          t          |                    d                    |                    d          d}d                    d |                                D                       }t          |           dd	i}t          j
        d
||          }|                                }|d         }t          |           t          d|i          S d S )NPOSTr9   
reportTypedate)
article_idrW   rX   
c                 "    g | ]\  }}| d | S z:  .0rR   rS   s      r
   
<listcomp>z)Get_production_report.<locals>.<listcomp>Y   s*    UUUJC////UUUr   Content-Typeapplication/jsonz<https://thingsaccess.com/rfid/index.php/Api/productionReportr   headersr   
data_skillr   methodr   r$   r%   r   rI   joinrJ   r   postr   r	   r/   re   raw_datard   r   	data_sends          r
   Get_production_reportrm   O   s   >>>nz',''((4..dhh|4455HHV$$
 

 99UU*BRBRBTBTUUUVVj!#56=!_fp  zA  B  B  BMMOO	z*
j\:6777 r   c                 \   t          |            | j        dk    rt          j        | j                  }|                    d          t          |                    d                    |                    d          |                    d          d}d                    d |                                D                       }t          |           d	d
i}t          j
        d||          }|                                }|d         }t          |           t          d|i          S d S )NrV   r9   rW   
start_dateend_date)operator_idrW   	startDateendDaterZ   c                 "    g | ]\  }}| d | S r\   r]   r^   s      r
   r`   z(Get_operators_report.<locals>.<listcomp>m   s*    !Y!Y!Y
US"3"3E"3"3!Y!Y!Yr   ra   rb   z;https://thingsaccess.com/rfid/index.php/api/wageCalculationrc   r   re   rf   rj   s          r
   Get_operators_reportru   b   s&   W~~~
.F
"
":gl++D#xx~~!$((<"8"899!XXl3388J//	 J yy!Y!YjFVFVFXFX!Y!Y!YZZH*%'9:G}%bis  }D  E  E  EH I":.J*z :;;;! #
"r   )django.shortcutsr   r   django.httpr   r   pandasr(   r   numpyrM   r   r   r   r5   rT   rm   ru   r]   r   r
   <module>rz      s    # # # # # # % % % % % % $ $ $ $ $ $          6 6 6) ) )
C C C/ / /"&/ &/ &/P8 8 8&< < < < <r   