global class SSOpporToSSBDallRepBatch implements Database.Batchable<sObject> {
	/*执行Batch，建立SS_询价产品清单（SS_Opportunity_detail_product__c）和SSBD_All_Report（SSBD_All_Report__c）
	的对应关系:
		从SSBD_All_Report__c中拷贝出询价Id和SSBD_All_Report__c.id，通过SSBD_All_Report__c和SS_询价产品清单共有的
		询价id来建立两者之间的对应关系
	*/
	String query;
	List<Id> OppoIDList;
	global SSOpporToSSBDallRepBatch(List<id> elementID) {
		
	}
	global SSOpporToSSBDallRepBatch(boolean Single) {
		
	}
	global SSOpporToSSBDallRepBatch() {
		
	}
	global Database.QueryLocator start(Database.BatchableContext BC) {
		query	=	'SELECT Id,OpportunityName__c, OpportunityID__c FROM SSBD_All_Report__c';
		return Database.getQueryLocator(query);
	}

	global void execute(Database.BatchableContext BC, List<sObject> scope) {
		List<SSBD_All_Report__c>	SARList	=	new	List<SSBD_All_Report__c>();
		SARList	=	scope;
		Map<id,id>	SAR_id_Map	=	new	Map<id,id>();
		List<id>	OppoIdBatchList	=	new	List<id>();
		for(SSBD_All_Report__c	ssr	:	SARList){
			OppoIdBatchList.add(ssr.OpportunityID__c);
			SAR_id_Map.put(ssr.OpportunityID__c, ssr.id);
		}
		system.debug('OppoIdBatchList::::'+OppoIdBatchList);
		List<SS_Opportunity_detail_product__c>	SSopdList	=	new	List<SS_Opportunity_detail_product__c>();
		List<SS_Opportunity_detail_product__c>	SSopdListUpdate	=	new	List<SS_Opportunity_detail_product__c>();
		
		SSopdList	=	[SELECT	
								Id, 
								OpportunityName__c, 
								SSBD_All_Report_ID__c, 
								OpportunityID__c
						FROM
								SS_Opportunity_detail_product__c
						where	
								OpportunityName__c	in:	OppoIdBatchList
						];
		system.debug('SSopdList::::'+SSopdList);
		for(	SS_Opportunity_detail_product__c	sodp	:	SSopdList	){
			sodp.SSBD_All_Report_ID__c	=	SAR_id_Map.get(sodp.OpportunityID__c);
			SSopdListUpdate.add(sodp);
		}
		update	SSopdListUpdate;

	}
	
	global void finish(Database.BatchableContext BC) {
		
	}
	
}