|  | @@ -152,6 +152,43 @@ class TongCe:
 | 
	
		
			
				|  |  |              (%s, %s, 1, 'binren', now())
 | 
	
		
			
				|  |  |      '''
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    sql_7 = '''
 | 
	
		
			
				|  |  | +            SELECT 
 | 
	
		
			
				|  |  | +                a.testcase_id,
 | 
	
		
			
				|  |  | +                a.uuid,
 | 
	
		
			
				|  |  | +                GROUP_CONCAT(
 | 
	
		
			
				|  |  | +                    DISTINCT b.sub_option_content
 | 
	
		
			
				|  |  | +                )
 | 
	
		
			
				|  |  | +            FROM
 | 
	
		
			
				|  |  | +                f_t_daren_score_2 a
 | 
	
		
			
				|  |  | +            LEFT JOIN d_shangju_tiku_02 b ON a.score = b.sub_option_id
 | 
	
		
			
				|  |  | +            WHERE
 | 
	
		
			
				|  |  | +                a.testcase_id IN (84, 85, 86, 87)
 | 
	
		
			
				|  |  | +            AND b.father_id IN (47, 48, 234, 254)
 | 
	
		
			
				|  |  | +            and a.sub_question_id = b.sub_question_id and a.testcase_id = b.testcase_id
 | 
	
		
			
				|  |  | +            GROUP BY
 | 
	
		
			
				|  |  | +                a.testcase_id,
 | 
	
		
			
				|  |  | +                a.uuid
 | 
	
		
			
				|  |  | +    '''
 | 
	
		
			
				|  |  | +    sql_8 = '''
 | 
	
		
			
				|  |  | +            SELECT
 | 
	
		
			
				|  |  | +                a.uuid,
 | 
	
		
			
				|  |  | +                a.title,
 | 
	
		
			
				|  |  | +                a.testcase_id,
 | 
	
		
			
				|  |  | +                b.father_id,
 | 
	
		
			
				|  |  | +                b.father_content,
 | 
	
		
			
				|  |  | +                b.sub_option_id,
 | 
	
		
			
				|  |  | +                b.sub_option_content
 | 
	
		
			
				|  |  | +            FROM
 | 
	
		
			
				|  |  | +                f_t_daren_score_2 a
 | 
	
		
			
				|  |  | +            LEFT JOIN d_shangju_tiku_02 b ON a.score = b.sub_option_id
 | 
	
		
			
				|  |  | +            WHERE
 | 
	
		
			
				|  |  | +                a.testcase_id = b.testcase_id
 | 
	
		
			
				|  |  | +            AND a.sub_question_id = b.sub_question_id
 | 
	
		
			
				|  |  | +            AND a.testcase_id IN (84, 85, 86, 87)
 | 
	
		
			
				|  |  | +    '''
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      def __init__(self):
 | 
	
		
			
				|  |  |          self.shangju_db = MysqlDB('shangju')
 | 
	
		
			
				|  |  |          self.marketing_db = MysqlDB('bi_report')
 | 
	
	
		
			
				|  | @@ -221,6 +258,27 @@ class TongCe:
 | 
	
		
			
				|  |  |              self.linshi_db.add_some(self.sql_6, dispaly_data)
 | 
	
		
			
				|  |  |          return {'插入数据条数': len(dispaly_data), 'scores': dispaly_data}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    # 同策答题人身份信息整理
 | 
	
		
			
				|  |  | +    # 性别父题id: 47
 | 
	
		
			
				|  |  | +    # 年龄父题id:48
 | 
	
		
			
				|  |  | +    # 支付力父题id:234
 | 
	
		
			
				|  |  | +    # 城市父题id: 254
 | 
	
		
			
				|  |  | +    def tongce_answer_info(self):
 | 
	
		
			
				|  |  | +        people_info = self.marketing_db.select(self.sql_7)
 | 
	
		
			
				|  |  | +        people_dict = {}
 | 
	
		
			
				|  |  | +        for pi in people_info:
 | 
	
		
			
				|  |  | +            people_dict[pi[1] + str(pi[0])] = pi
 | 
	
		
			
				|  |  | +        answers = self.marketing_db.select(self.sql_8)
 | 
	
		
			
				|  |  | +        result = []
 | 
	
		
			
				|  |  | +        for aw in answers:
 | 
	
		
			
				|  |  | +            aw = list(aw)
 | 
	
		
			
				|  |  | +            people = people_dict.get(aw[0] + str(aw[2]))
 | 
	
		
			
				|  |  | +            if people:
 | 
	
		
			
				|  |  | +                for pl in str(people[2]).split(','):
 | 
	
		
			
				|  |  | +                    aw.append(pl)
 | 
	
		
			
				|  |  | +            result.append(aw)
 | 
	
		
			
				|  |  | +        return result
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  if __name__ == '__main__':
 | 
	
		
			
				|  |  |      pass
 |