
    j                     2    d dl mZ dedeeef         fdZdS )    )	query_allzjhmreturnc                    d}t          |d| i          }|sdddifS i }i }|D ]e}|                    d          }|                    d          }|r|                    dd          ||<   |r|                    |d	          d	z   ||<   fd}|rd
                    d t          t	          |                    D                       }	d t          |                                          D             }
d|	 d}t          ||
          }t	          |          }t          |dz  d          }t          d |	                                D                       }|rdnd}t          ||z   d          }t	          |          ||||d}||fS )Na  
        SELECT DISTINCT x2."xyrxx_sfzh", x2."xyrxx_xm",
               x1."ajxx_join_ajxx_ajbh"
        FROM "ywdata"."zq_zfba_xyrxx" x1
        JOIN "ywdata"."zq_zfba_xyrxx" x2
          ON x2."ajxx_join_ajxx_ajbh" = x1."ajxx_join_ajxx_ajbh"
          AND x2."xyrxx_sfzh" <> x1."xyrxx_sfzh"
        WHERE x1."xyrxx_sfzh" = %(zjhm)s
          AND NULLIF(BTRIM(COALESCE(x2."xyrxx_sfzh", '')), '') IS NOT NULL
    r   r   co_suspect_count
xyrxx_sfzhajxx_join_ajxx_ajbhxyrxx_xm    z, c                     g | ]}d | d	S )z%(sz)s ).0is     C/home/longshao/multi-rider-rag/modules/score/services/dim_social.py
<listcomp>z%calc_social_score.<locals>.<listcomp>    s     !S!S!S!++++!S!S!S    c                      i | ]\  }}d | |S )sr   )r   r   sfzhs      r   
<dictcomp>z%calc_social_score.<locals>.<dictcomp>!   s$    QQQGAt'a''4QQQr   zp
            SELECT zjhm, total_score
            FROM "jcgkzx_monitor"."wcnr_score"
            WHERE zjhm IN (z ) AND total_score >= 60
              c              3   "   K   | ]
}|d k    V  dS )r   Nr   )r   cnts     r   	<genexpr>z$calc_social_score.<locals>.<genexpr>,   s&      CC3!8CCCCCCr   
   )r   high_risk_contactscontact_scorehas_gang
gang_bonus)
r   getjoinrangelen	enumeratekeysminanyvalues)r   co_suspects_sqlco_suspectsunique_suspectscase_suspect_countrowr   ajbhhigh_risk_countplaceholdersparams	score_sqlhigh_risk_rowsr   r    r!   scoredetails                     r   calc_social_scorer8      s   	O Ofd^<<K *%q)))O K Kww|$$ww,-- 	<$'GGJ$;$;OD! 	K'9'='=dA'F'F'Jt$O 	.yy!S!SuS=Q=Q7R7R!S!S!STTQQy9M9M9O9O/P/PQQQ )  	
 #9f55n--!+Q//MCC'9'@'@'B'BCCCCCH%AJ
*B//E00-&  F &=r   N)shared.db.kingbaser   strtupleintdictr8   r   r   r   <module>r>      sL    ( ( ( ( ( (3C 3E#t)$4 3 3 3 3 3 3r   