|  | @@ -343,6 +343,7 @@ class ParseAddCampaignOrAddGroupRequest(object):
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          self.res_data['group_list'] = []
 | 
	
		
			
				|  |  |          group_cnt = 1
 | 
	
		
			
				|  |  | +        batch_group_params_to_db = []
 | 
	
		
			
				|  |  |          for video in self.video:
 | 
	
		
			
				|  |  |              group_uuid = str(uuid.uuid4())
 | 
	
		
			
				|  |  |              group_name = group_params_to_db['group_name'] + '-' + str(group_cnt)
 | 
	
	
		
			
				|  | @@ -352,11 +353,7 @@ class ParseAddCampaignOrAddGroupRequest(object):
 | 
	
		
			
				|  |  |              single_group_params_to_db['group_uuid'] = group_uuid
 | 
	
		
			
				|  |  |              single_group_params_to_db['group_name'] = group_name
 | 
	
		
			
				|  |  |              single_group_params_to_db['create_time'] = datetime.datetime.now()
 | 
	
		
			
				|  |  | -            df = pd.DataFrame.from_dict(single_group_params_to_db, orient='index').T
 | 
	
		
			
				|  |  | -            df.to_sql(name="ctop_ai_kuaishou_unit_level_operation_record",
 | 
	
		
			
				|  |  | -                      con=engine,
 | 
	
		
			
				|  |  | -                      if_exists='append',
 | 
	
		
			
				|  |  | -                      index=False)
 | 
	
		
			
				|  |  | +            batch_group_params_to_db.append(single_group_params_to_db)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              # 拼装返回json的组信息
 | 
	
		
			
				|  |  |              single_group_params_to_request = group_params_to_request.copy()
 | 
	
	
		
			
				|  | @@ -367,6 +364,7 @@ class ParseAddCampaignOrAddGroupRequest(object):
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              # 拼装组下面创意的信息
 | 
	
		
			
				|  |  |              creative_cnt = 1
 | 
	
		
			
				|  |  | +            batch_creative_params_to_db = []
 | 
	
		
			
				|  |  |              for image_md5 in video['imageList'][: self.advertiser_strategy['image_cnt']]:
 | 
	
		
			
				|  |  |                  creative_uuid = str(uuid.uuid4())
 | 
	
		
			
				|  |  |                  creative_name = creative_params_to_db['creative_name'] + '_' + str(creative_cnt)
 | 
	
	
		
			
				|  | @@ -377,11 +375,7 @@ class ParseAddCampaignOrAddGroupRequest(object):
 | 
	
		
			
				|  |  |                  single_creative_params_to_db['photo_id'] = int(video['photo_id'])
 | 
	
		
			
				|  |  |                  single_creative_params_to_db['image_md5'] = image_md5
 | 
	
		
			
				|  |  |                  single_creative_params_to_db['create_time'] = datetime.datetime.now()
 | 
	
		
			
				|  |  | -                df = pd.DataFrame.from_dict(single_creative_params_to_db, orient='index').T
 | 
	
		
			
				|  |  | -                df.to_sql(name="ctop_ai_kuaishou_creative_level_operation_record",
 | 
	
		
			
				|  |  | -                          con=engine,
 | 
	
		
			
				|  |  | -                          if_exists='append',
 | 
	
		
			
				|  |  | -                          index=False)
 | 
	
		
			
				|  |  | +                batch_creative_params_to_db.append(single_creative_params_to_db)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  single_creative_params_to_request = creative_params_to_request.copy()
 | 
	
		
			
				|  |  |                  single_creative_params_to_request['creative_uuid'] = creative_uuid
 | 
	
	
		
			
				|  | @@ -392,9 +386,22 @@ class ParseAddCampaignOrAddGroupRequest(object):
 | 
	
		
			
				|  |  |                  # 单个创意信息加入到组里面的 creative_list 中
 | 
	
		
			
				|  |  |                  single_group_params_to_request['creative_list'].append(single_creative_params_to_request)
 | 
	
		
			
				|  |  |                  creative_cnt += 1
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            creative_df = pd.DataFrame(batch_creative_params_to_db)
 | 
	
		
			
				|  |  | +            creative_df.to_sql(name="ctop_ai_kuaishou_creative_level_operation_record",
 | 
	
		
			
				|  |  | +                               con=engine,
 | 
	
		
			
				|  |  | +                               if_exists='append',
 | 
	
		
			
				|  |  | +                               index=False)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              # 组和创意信息添加到最终返回数据 group_list 中
 | 
	
		
			
				|  |  |              self.res_data['group_list'].append(single_group_params_to_request)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        group_df = pd.DataFrame(batch_group_params_to_db)
 | 
	
		
			
				|  |  | +        group_df.to_sql(name="ctop_ai_kuaishou_unit_level_operation_record",
 | 
	
		
			
				|  |  | +                        con=engine,
 | 
	
		
			
				|  |  | +                        if_exists='append',
 | 
	
		
			
				|  |  | +                        index=False)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          self.res_data['account_id'] = self.account_id
 | 
	
		
			
				|  |  |          self.res_data['campaign_id'] = self.campaign_id
 | 
	
		
			
				|  |  |  
 |