public with sharing class ISO_DemandOAD_PDFController {
	//公共变量：list
	public List<IS_Opportunity_Demand_Operating__c> pageQueryoDoList{get;set;}
	public List<IS_Opportunity_Demand_Demonstration__c> pageQueryoDDList{get;set;}
	//公共变量：对象数据
	public IS_Opportunity_Demand_Operating__c pageShwoElement{get;set;}
	public String ISodcIdStr {get;set;}
	public String OpporIdStr {get;set;}
	public String fileName {get;set;} 
	public IS_Opportunity_Demand__c ISOhead {get;set;}
	public ISOpportunityDemandInfo pageShowSet{get;set;}
	public ISOpportunityDemandInfo pageShowSetClone{get;set;}
	public List<IS_Opportunity_Demand__c> ISOheadList{get;set;}
	//页面用公共变量
	public String NowDate{get;set;}
	public integer PageSum{get;set;}
	public ISO_DemandOAD_PDFController() {
		ISodcIdStr = ApexPages.currentPage().getParameters().get('id');
		OpporIdStr = ApexPages.currentPage().getParameters().get('OppoerID');
		fileName = ApexPages.currentPage().getParameters().get('fileName');
		ApexPages.currentPage().getHeaders().put('content-disposition','inline;filename='+fileName+'.pdf');
		pageQueryoDoList = new List<IS_Opportunity_Demand_Operating__c>();
		pageQueryoDDList = new List<IS_Opportunity_Demand_Demonstration__c>();
		pageShwoElement = new IS_Opportunity_Demand_Operating__c();
		pageShowSetClone = new ISOpportunityDemandInfo();
		pageShowSet = new ISOpportunityDemandInfo();
		ISOheadList = new List<IS_Opportunity_Demand__c>();

	}
	public void init(){ 
		NowDate = System.now().format('yyyy-MM-dd');
		ISOhead = new IS_Opportunity_Demand__c();
		if(ISodcIdStr!=''&&ISodcIdStr!=null){
			pageQueryoDDList = [ SELECT 
									Id,
									IsDeleted,
									Name,
									Microphone_Exsit_TF__c,
									IS_Opportunity_Demand__c,
									Demand_Demonstration_Area_Sum__c,
									Display_Separate_TF__c,
									Mobile_Equip_Controller_TF__c,
									Display_Equipment_List__c,
									HD_Camera_Panorama_TF__c,
									Microphone_Type_List__c,
									Position_To_Operating_Room_List__c,
									Share_With_Other_Firm_TF__c,
									Other_Require_Text__c,
									Microphone_Number__c,
									Brand_Name__c 
								FROM 
									IS_Opportunity_Demand_Demonstration__c
								where
									IS_Opportunity_Demand__c =:ISodcIdStr
								];
			ISOheadList = [SELECT 
									Id,
									OwnerId,
									IsDeleted,
									Name,
									Phone_Of_Nuers__c,
									Phone_Of_HDOA__c,
									Phone_of_ImfD__c,
									Phone_of_GAD__c,
									Phone_of_EDC__c,
									Phone_of_CCD__c,
									Lead_Of_Nurses__c,
									Opportunity_ID__r.Opportunity_No__c,
									Opportunity_ID__r.State__c,
									Opportunity_ID__r.old_Oppo_No__c,
									Lead_Of_Department_Of_Anesthesia__c,
									Lead_Of_Information_Department__c,
									Lead_of_General_Affairs_Department__c,
									Lead_of_Equipment_Department__c,
									Lead_of_Capital_Construction_Department__c,
									Table_Create_Date__c,
									Public_Hospital_TF__c,
									Private_Hospital_TF__c,
									Other_Hospital_TF__c,
									Operating_Room_Sum__c,
									Demand_Demonstration_Cnt__c,
									OperatingCnt__c,
									Demonstration_Area_Sum__c,
									Preparation_Stage_TF__c,
									Building_Phase_Stage_TF__c,
									Purification_Construction_Stage_TF__c,
									Other_Stage_Text__c,
									Operating_Room_Plane_Graph_TF__c,
									Head_Mast_Position_Graph_TF__c,
									Operating_Room_Clear_Graph_TF__c,
									Demonstration_Area_Plane_Graph_TF__c,
									Buliding_Plane_Graph_TF__c,
									Other_Enginee_List_Text__c,
									Func_SOD_Status__c
							FROM 
									IS_Opportunity_Demand__c
							where
									Id  =:  ISodcIdStr
			];
			if(ISOheadList.size()==1){
				ISOhead = ISOheadList[0];
				ISOhead.Operating_Room_Sum__c = ISOhead.OperatingCnt__c;
				ISOhead.Demonstration_Area_Sum__c = ISOhead.Demand_Demonstration_Cnt__c;
			}else{
				ISOhead = new IS_Opportunity_Demand__c(Operating_Room_Sum__c = 1,Demonstration_Area_Sum__c = 1);
			}
			pageQueryoDoList = [SELECT Id,
									Name,
									IS_Opportunity_Demand__c,
									Operating_Room_Num_or_Name__c,
									Operating_Room_Position_Area__c,
									Operating_Room_Position_Building__c,
									Operating_Room_Position_Stage__c,
									Operating_Room_Length__c,
									Operating_Room_Width__c,
									Operating_Room_Build_Heigth__c,
									Operating_Room_Top_heigth__c,
									isChirurgery_TF__c,
									isGynaecology_TF__c,
									isUrological_TF__c,
									isOrthopedics_TF__c,
									isENT_TF__c,
									isPlanned_TF__c,
									isAural_Sursery_TF__c,
									isGastroenterology_TF__c,
									isRespirationDept_TF__c,
									isInvasive_Technology_TF__c,
									Wall_Mounting_Type_TF__c,
									Dept_Others_Text__c,
									Centre_Air_Support_System_TF__c,
									Purify_Operating_Room_TF__c,
									Lamp_Panel_Type_List__c,
									Lamp_Panel_Sum__c,
									Planning_Blue_Room_TF__c,
									Need_to_Transform_TF__c,
									Centralized_Control_TF__c,
									Reform_Lamp_Plane_List__c,
									Reform_Lamp_Plane_Sum__c,
									Equipment_Centralized_Control_TF__c,
									OTV_S190_TF__c,
									OTV_S7_Pro_TF__c,
									T3D_System_TF__c,
									CV_180_TF__c,
									CV_190_TF__c,
									Olympus_Endoscope_Other_Text__c,
									UHI_4_TF__c,
									UHI_3_TF__c,
									Storz_Main__c,
									Storz_Main_Model__c,
									Stryker_Main__c,
									Stryker_Main_Model__c,
									Compatible_Signal_TF__c,
									Compatible_Signal_Format_Text__c,
									Compatible_Signal_Sum__c,
									Party_a_Purchase_TF__c,
									Olympus_Package_Purchase_TF__c,
									Party_A_Hold_TF__c,
									Laparoscopy_Tower_TF__c,
									Anesthesia_Tower_TF__c,
									Surgical_Tower_TF__c,
									Display_Tower_Radiation_TF__c,
									Other_Tower_TF__c,
									Brand_of_Laparoscopy_Tower_List__c,
									Other_Brand_Laparoscopy_Text__c,
									Laparoscopy_Tower_Type_List__c,
									Laparoscopy_Tower_Model_Desciption_Text__c,
									Brand_Surgical_Tower_List__c,
									Surgical_Tower_Model_Or_Decription_Text__c,
									Brand_Of_Display_Tower_Radiation_List__c,
									Display_Tower_Model_Or_Description__c,
									Other_Tower_Brand__c,
									Other_Medic_Displayer__c,
									Performanc_60inch_Display__c ,
									Other_Tower_Brand_List__c,
									Other_Tower_Model_Description__c,
									Purchase_Plan_SpringArm_List__c,
									Brand_Of_SpringArm__c,
									Other_FullHD_Display__c ,
									SpringArm_AC2000_Sum__c,
									SpringArm_AC3000_Sum__c,
									SpringArm_Other_Name__c,
									Shadowless_Lamp_Procurement_Plan__c,
									Other_Main_And_Model_Text__c,
									Equipment_Centralized_Control_List__c,
									Brand_Of_Shadowless_Lamp_List__c,
									ShadowlessLamp_Model_Or_Description_Text__c,
									Shadowless_Lamp_Type_List__c,
									Brand_Of_Mid_Camera_List__c,
									Mid_Camera_Model_Or_Descirption_Text__c,
									Mid_Camera_Signal_Type_List__c,
									Side_Camera_Procurement_Plan__c,
									Brand_Of_Side_Camera__c,
									Side_Camera_Model_Or_Description_Text__c,
									Side_Camera_Signal_Type_List__c,
									Endoscopic_Other_Video_Src_ListM__c,
									OEV_262_2D_Sum__c,
									Other_2D_Sum__c,
									Other_2D_Name__c,
									Dept_Others_TF__c,
									Olympus_Endoscope_2_Model_List__c,
									Pneumoperitoneum_Other__c,
									Other_Main_And_Model_TF__c,
									Energy_Portable_ESG_400_TF__c,
									Energy_Portable_USG_400_TF__c,
									Energy_Portable_UES_40_TF__c,
									Energy_Portable_SSG_2_TF__c,
									Energy_Portable_Other_Text__c,
									Covidien_Brand_TF__c,
									Force_FX_C_Brand_TF__c,
									Force_Triad_Brand_TF__c,
									ERBE_Brand_TF__c,
									VIO300D_Brand_TF__c,
									Anesthesia_Tower_Text_Description__c,
									Brand_Of_Anesthesia_Tower_List__c,
									Operating_Room_Plan__c,
									Brand_Of_Operating_Bed_List__c,
									Operating_Bed_Model_Or_Description_Text__c,
									Operating_Equipment_Ctrl_TF__c,
									Other_Vs_Arm_Type_C_TF__c,
									Other_Vs_DSA_TF__c,
									Other_Vs_EUS_TF__c,
									Other_Vs_Type_B_ultrasonic_TF__c,
									Other_Vs_Other_Text__c,
									LMD_2451TC_Sum__c,
									LMD_3251TC_Sum__c,
									Other_3D_Displayer_Sum__c,
									Size60_3D_Displayer_Sum__c,
									Other_3D_Displayer__c,
									Sony_42_3D_Displayer_Pro_Sum__c,
									In_Cell_InstallType_TF__c,
									Display_60_Install_TF__c,
									IMF_IO_System__c,
									IMH_20_Model_TF__c,
									IMH_10_Model_TF__c,
									Install_Type_60Display_List__c,
									MultiTouch_Display_Equip_Ctrl_TF__c,
									Wireless_Music_Input_Ctrl_TF__c,
									Reserved_Video_Channels_Sum__c,
									Reserved_Audio_Channels_Sum__c,
									Remarks_Text__c 
							FROM 
									IS_Opportunity_Demand_Operating__c
							where
									IS_Opportunity_Demand__c =: ISodcIdStr
								];
		}else{
			ISOhead = new IS_Opportunity_Demand__c(Operating_Room_Sum__c = 1,Demonstration_Area_Sum__c = 1);
		}
		
		if(pageQueryoDoList.size()==1){
			pageShwoElement = pageQueryoDoList[0];
		}else if(pageQueryoDoList.size()==0){
			pageQueryoDoList.add(new IS_Opportunity_Demand_Operating__c(name=' '));
		}
		if(pageQueryoDDList.size()==0){
			pageQueryoDDList.add(new IS_Opportunity_Demand_Demonstration__c(name=' '));
		}
		System.debug('ididididid'+ISOhead);
		System.debug('ddddd'+pageQueryoDoList.size());
		pageShowSet = new ISOpportunityDemandInfo(ISOhead,pageQueryoDoList,pageQueryoDDList);
		PageSum = 1+pageQueryoDoList.size()*6 +pageQueryoDDList.size();
		
	}
	class ISOpportunityDemandInfo{
		//主题数据组
		public IS_Opportunity_Demand__c ISOdcInfoHead{get;set;}
		public List<IS_Opportunity_Demand_Operating__c> ISodoc_InfoList {get;set;}
		public List<IS_Opportunity_Demand_Demonstration__c> ISOdd_InfoList{get;set;}
		//验证关系
		boolean isCheckPass{get;set;}
		public ISOpportunityDemandInfo(){
			isCheckPass =false;
		}
		public ISOpportunityDemandInfo(IS_Opportunity_Demand__c ISHead,List<IS_Opportunity_Demand_Operating__c> ISodocInfoList,List<IS_Opportunity_Demand_Demonstration__c> ISOddInfoList){
			isCheckPass = false;
			this.ISOdcInfoHead = ISHead;
			this.ISodoc_InfoList = ISodocInfoList;
			this.ISOdd_InfoList =ISOddInfoList;
			if(ISOdcInfoHead!=null){
				if(ISOdcInfoHead.Demonstration_Area_Sum__c!=ISOdd_InfoList.size()
					||ISOdcInfoHead.Operating_Room_Sum__c!=ISodoc_InfoList.size()
						||ISOdd_InfoList.size()==0
							||ISodoc_InfoList.size()==0){
				}else{
					isCheckPass = true;
				}
			}
		}
	}
}