@isTest
private class ISO_DemandOperAndDemonsControllerTest {
	

	   
	@isTest static void test_method_One() {
		// Implement test code
		Profile pf = [select Id from Profile where Id =:system.label.ProfileId_SystemAdmin];
		RecordType rtHP = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'HP'];
		RecordType rtDepClass = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'Department_Class_ENT'];           // 耳鼻喉科
		RecordType rtDep = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'Department_ENT'];
		RecordType rtDoc = [select id from RecordType where IsActive = true and SobjectType = 'Contact' and DeveloperName =:'Doctor'];
		
		Address_Level__c al = new Address_Level__c();
		al.Name = '東京';
		al.Level1_Code__c = 'CN-99';
		al.Level1_Sys_No__c = '999999';
		insert al;
		Address_Level2__c al2 = new Address_Level2__c();
		al2.Level1_Code__c = 'CN-99';
		al2.Level1_Sys_No__c = '999999';
		al2.Level1_Name__c = '東京';
		al2.Name = '渋谷区';
		al2.Level2_Code__c = 'CN-9999';
		al2.Level2_Sys_No__c = '9999999';
		al2.Address_Level__c = al.id;
		insert al2;
	// 病院を作る
		Account hospital = new Account();
	   
		String rid = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
		hospital.Name = 'test hospital';
		hospital.recordtypeId = rid;
		hospital.Is_Active__c = '有効';
		insert hospital;

		// 戦略科室を得る
		Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
		// 診療科を作る
		Account dep = new Account();
		dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
		dep.Name = 'test dep';
		dep.AgentCode_Ext__c = '9999998';
		dep.ParentId = strategicDep[0].Id;
		dep.Department_Class__c = strategicDep[0].Id;
		dep.Hospital__c = hospital.Id;
		insert dep;
	  

		List<Contact> conList = new List<Contact>();
		Contact con1 = new Contact();
		con1.Firstname='ZZ1';
		con1.LastName = '取引先責任者1';
		con1.RecordTypeId = rtDoc.id;
		con1.AccountId = dep.Id;
		conList.add(con1);

		insert conList;
	RecordType Type = [select id from RecordType where DeveloperName='SI_Oppor'];
	String TypeID = Type.Id;
	Opportunity opp1 = new Opportunity();
		opp1.Name = '引合1';
		opp1.AccountId = dep.Id;
		opp1.Opportunity_Category__c = 'ENT';
		opp1.Trade__c = '外貿';
		opp1.StageName = '引合';
		opp1.CurrencyIsoCode = 'CNY';
		opp1.Close_Forecasted_Date__c = date.today().addMonths(1);
		opp1.CloseDate = date.today().addMonths(1);
		opp1.Competitor__c = 'B';
		opp1.Purchase_Type__c ='SI（手術室案件）';
		opp1.Sales_Root__c = 'OCM直接販売';
		opp1.Hospital__c = hospital.id;
		//opp1.Department_Class__c = accDepClass.id;
		opp1.StageName = '引合';
		opp1.RecordTypeid = TypeID;
	insert opp1;
	
	
	IS_Opportunity_Demand__c ISOhead = new IS_Opportunity_Demand__c();
	ISOhead.Opportunity_ID__c = opp1.id;
	ISOhead.Public_Hospital_TF__c = true;
	ISOhead.Preparation_Stage_TF__c = true;
	ISOhead.Operating_Room_Plane_Graph_TF__c = true;
	ISOhead.Demonstration_Area_Plane_Graph_TF__c = true;
	insert ISOhead;
	IS_Opportunity_Demand_Operating__c iso_Odo = new IS_Opportunity_Demand_Operating__c();
	iso_Odo.Dept_Others_TF__c = true;
	iso_Odo.Operating_Room_Position_Area__c = '2333';
	iso_Odo.Equipment_Center_Crtl_Minor_TF__c = true;
	iso_Odo.Compatible_Signal_TF__c  = true;
	iso_Odo.Party_A_Hold_TF__c = true;
	iso_Odo.Purchase_Plan_SpringArm_List__c = '甲方已有';
	iso_Odo.Shadowless_Lamp_Procurement_Plan__c = '甲方已有';
	iso_Odo.Shadowless_Lamp_Procurement_Plan__c = '甲方已有';
	iso_Odo.Side_Camera_Procurement_Plan__c = '甲方已有';
	iso_Odo.Operating_Room_Plan__c = '甲方已有';
	iso_Odo.Equipment_Centralized_Control_List__c='控制术野摄像机';
	iso_Odo.Anesthesia_Tower_TF__c   =  true;
	iso_Odo.Surgical_Tower_TF__c =  true;
	iso_Odo.Display_Tower_Radiation_TF__c  =  true;
	iso_Odo.Other_Tower_TF__c   =  true;
	iso_odo.Laparoscopy_Tower_TF__c =  true;
	iso_Odo.Anesthesia_Tower_TF__c   =  true;
	iso_Odo.Surgical_Tower_TF__c =  true;
	iso_Odo.Display_Tower_Radiation_TF__c  =  true;
	iso_Odo.Other_Tower_TF__c =  true;
	iso_Odo.IS_Opportunity_Demand__c = ISOhead.id;
	iso_Odo.OTV_S190_TF__c = false;
	iso_Odo.OTV_S7_Pro_TF__c = false;
	iso_Odo.T3D_System_TF__c = false;
	iso_Odo.CV_180_TF__c = false;
	iso_Odo.CV_190_TF__c = false;
	iso_Odo.Olympus_Endoscope_Other_Text__c = '';
	iso_Odo.Brand_Of_SpringArm__c = '';
	insert iso_Odo;
	IS_Opportunity_Demand_Operating__c iso_Odo2 = new IS_Opportunity_Demand_Operating__c();
	iso_Odo2.Dept_Others_TF__c = true;
	iso_Odo2.Equipment_Center_Crtl_Minor_TF__c = true;
	iso_Odo2.Compatible_Signal_TF__c  = true;
	iso_Odo2.Party_A_Hold_TF__c = true;
	iso_Odo2.Purchase_Plan_SpringArm_List__c = '甲方已有';
	iso_Odo2.Shadowless_Lamp_Procurement_Plan__c = '甲方已有';
	iso_Odo2.Shadowless_Lamp_Procurement_Plan__c = '甲方已有';
	iso_Odo2.Side_Camera_Procurement_Plan__c = '甲方已有';
	iso_Odo2.Operating_Room_Plan__c = '甲方已有';
	iso_Odo2.Equipment_Centralized_Control_List__c='控制术野摄像机';
	iso_Odo2.Anesthesia_Tower_TF__c   =  true;
	iso_Odo2.Surgical_Tower_TF__c =  true;
	iso_Odo2.Display_Tower_Radiation_TF__c  =  true;
	iso_Odo2.Other_Tower_TF__c   =  true;
	iso_odo2.Laparoscopy_Tower_TF__c =  false;
	iso_Odo2.Anesthesia_Tower_TF__c   =  true;
	iso_Odo2.Surgical_Tower_TF__c =  true;
	iso_Odo2.Display_Tower_Radiation_TF__c  =  true;
	iso_Odo2.Other_Tower_TF__c =  true;
	iso_Odo2.IS_Opportunity_Demand__c = ISOhead.id;
	iso_Odo2.Operating_Room_Position_Area__c = '2222';
	iso_odo2.Operating_Room_Position_Building__c  = null;
	iso_Odo2.OTV_S190_TF__c = false;
	iso_Odo2.OTV_S7_Pro_TF__c = false;
	iso_Odo2.T3D_System_TF__c = false;
	iso_Odo2.CV_180_TF__c = false;
	iso_Odo2.CV_190_TF__c = false;
	iso_Odo2.Olympus_Endoscope_Other_Text__c = '';
	iso_Odo2.Brand_Of_SpringArm__c = '';
	insert iso_Odo2;

	IS_Opportunity_Demand_Demonstration__c iso_odd = new IS_Opportunity_Demand_Demonstration__c();
	iso_odd.IS_Opportunity_Demand__c = ISOhead.id;
	insert iso_odd;

	PageReference page = new PageReference('apex/ISO_DemandOperAndDemons?retURL=%2F' + ISOhead.Id + '&scontrolCaching=1&_CONFIRMATIONTOKEN=VmpFPSxNakF4Tnkwd09TMHlORlF3TVRveE5UbzBPUzQ1TVRSYSwySG84V2lfa2VFLVFaaE53SU9RckJHLFkyUTFNV1kx&common.udd.actions.ActionsUtilORIG_URI=%2F' + ISOhead.Id + '%2Fe&sfdc.override=1&id=' + ISOhead.Id );
    System.Test.setCurrentPage(page);
	ISO_DemandOperAndDemonsController iso = new ISO_DemandOperAndDemonsController();
	iso.init();
	iso.save();
	iso.completenessCheck();
	iso.abortCode = ISOhead.id;
	iso.init();

	}
	
	@isTest static void test_method_Two() {
		// Implement test code
		Profile pf = [select Id from Profile where Id =:system.label.ProfileId_SystemAdmin];
		RecordType rtHP = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'HP'];
		RecordType rtDepClass = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'Department_Class_ENT'];           // 耳鼻喉科
		RecordType rtDep = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'Department_ENT'];
		RecordType rtDoc = [select id from RecordType where IsActive = true and SobjectType = 'Contact' and DeveloperName =:'Doctor'];
		
		Address_Level__c al = new Address_Level__c();
		al.Name = '東京';
		al.Level1_Code__c = 'CN-99';
		al.Level1_Sys_No__c = '999999';
		insert al;
		Address_Level2__c al2 = new Address_Level2__c();
		al2.Level1_Code__c = 'CN-99';
		al2.Level1_Sys_No__c = '999999';
		al2.Level1_Name__c = '東京';
		al2.Name = '渋谷区';
		al2.Level2_Code__c = 'CN-9999';
		al2.Level2_Sys_No__c = '9999999';
		al2.Address_Level__c = al.id;
		insert al2;
	// 病院を作る
		Account hospital = new Account();
	   
		String rid = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
		hospital.Name = 'test hospital';
		hospital.recordtypeId = rid;
		hospital.Is_Active__c = '有効';
		insert hospital;

		//Account accHP = new Account();
		//accHP.Name = '病院1';
		//accHP.Grade__c = '一般';
		//accHP.OCM_Category__c = '一般';
		//accHP.Attribute_Type__c = '保険省';
		//accHP.Speciality_Type__c = '総合病院';
		//accHP.Is_Active__c = '有効';
		//accHP.State_Master__c = al.id;
		//accHP.City_Master__c = al2.id;
		//accHP.RecordTypeId = rid;
		//accHP.Valid_To__c = Date.today() + 2;
		//insert accHP;
		// 戦略科室を得る
		Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
		// 診療科を作る
		Account dep = new Account();
		dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
		dep.Name = 'test dep';
		dep.AgentCode_Ext__c = '9999998';
		dep.ParentId = strategicDep[0].Id;
		dep.Department_Class__c = strategicDep[0].Id;
		dep.Hospital__c = hospital.Id;
		insert dep;
		//Account accDepClass = [select id,name from account where parentId =:hospital.id and DeveloperName = 'Department_Class_OTH'];
		//accDepClass.Name = '戦略科室分類1';
		//accDepClass.Department_Class_Label__c = '耳鼻喉科';
		//accDepClass.Hospital_Department_Class__c = accHP.id;
		//accDepClass.ParentId = accHP.id;
		//accDepClass.RecordTypeId = rtDepClass.id;
		//insert accDepClass;
		//Account accDep = new Account();
		//accDep.Name = '診療科1';
		//accDep.Department_Class_Label__c = '診療科1';
		//accDep.Hospital__c = hospital.id;
		//accDep.ParentId = accDepClass.id;
		//accDep.Department_Class__c = accDepClass.id;
		//accDep.Department_Name__c = '診療科1';
		//accDep.CurrencyIsoCode = 'CNY';
		//accDep.RecordTypeId = rtDep.id;
		//insert accDep;
		List<Contact> conList = new List<Contact>();
		Contact con1 = new Contact();
		con1.Firstname='ZZ1';
		con1.LastName = '取引先責任者1';
		con1.RecordTypeId = rtDoc.id;
		con1.AccountId = dep.Id;
		conList.add(con1);

		insert conList;
	RecordType Type = [select id from RecordType where DeveloperName='SI_Oppor'];
	String TypeID = Type.Id;
	Opportunity opp1 = new Opportunity();
		opp1.Name = '引合1';
		opp1.AccountId = dep.Id;
		opp1.Opportunity_Category__c = 'ENT';
		opp1.Trade__c = '外貿';
		opp1.StageName = '引合';
		opp1.CurrencyIsoCode = 'CNY';
		opp1.Close_Forecasted_Date__c = date.today().addMonths(1);
		opp1.CloseDate = date.today().addMonths(1);
		opp1.Competitor__c = 'B';
		opp1.Purchase_Type__c ='SI（手術室案件）';
		opp1.Sales_Root__c = 'OCM直接販売';
		opp1.Hospital__c = hospital.id;
		//opp1.Department_Class__c = accDepClass.id;
		opp1.StageName = '引合';
		opp1.RecordTypeid = TypeID;
	insert opp1;
	List<String> ListOpp = new List<String>();
	ListOpp.add(opp1.Id);
	IS_Opportunity_Demand__c ISOhead = new IS_Opportunity_Demand__c();
	ISOhead.Opportunity_ID__c = opp1.id;
	ISOhead.Public_Hospital_TF__c = true;
	ISOhead.Preparation_Stage_TF__c = true;
	ISOhead.Operating_Room_Plane_Graph_TF__c = true;
	ISOhead.Demonstration_Area_Plane_Graph_TF__c = true;
	insert ISOhead;

	List<IS_Opportunity_Demand_Operating__c> odoList = new List<IS_Opportunity_Demand_Operating__c>();
	for(integer i = 0; i<7;i++){
		IS_Opportunity_Demand_Operating__c iso_Odo = new IS_Opportunity_Demand_Operating__c();
		iso_Odo.Dept_Others_TF__c = true;
		
		iso_Odo.IS_Opportunity_Demand__c = ISOhead.id;

		odoList.add(iso_odo);
	}
	insert odoList;

	PageReference page = new PageReference('apex/ISO_DemandOperAndDemons?id=' + ISOhead.Id +'' );
    System.Test.setCurrentPage(page);

	ISO_DemandOperAndDemonsController iso = new ISO_DemandOperAndDemonsController();
	iso.OpporIdStr = opp1.id;
	
	ISO_DemandOperAndDemonsController.synchronousSodWithOppor(ListOpp);
	iso.init();
	iso.save();
	iso.completenessCheck();
	
	iso.TargetName = 'Operating_Room';
	iso.pageShowSet.ISOdcInfoHead.Operating_Room_Sum__c = 4;
	iso.SetDetailSum();
	iso.TargetName = 'Demonstration';
	iso.pageShowSet.ISOdcInfoHead.Demonstration_Area_Sum__c = 2;
	iso.SetDetailSum();
	iso.TargetName = 'Operating_Room';
	iso.pageShowSet.ISOdcInfoHead.Demonstration_Area_Sum__c = 6;
	iso.SetDetailSum();
	iso.SearchPhone();
	iso.refreshDetail();
	iso.renturn();
	iso.sendMail();

	iso.ISodcIdStr = ISOhead.id;
	iso.init();

	}
	@isTest static void test_method_Three() {
		// Implement test code
				Profile pf = [select Id from Profile where Id =:system.label.ProfileId_SystemAdmin];
		RecordType rtHP = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'HP'];
		RecordType rtDepClass = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'Department_Class_ENT'];           // 耳鼻喉科
		RecordType rtDep = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'Department_ENT'];
		RecordType rtDoc = [select id from RecordType where IsActive = true and SobjectType = 'Contact' and DeveloperName =:'Doctor'];
		
		Address_Level__c al = new Address_Level__c();
		al.Name = '東京';
		al.Level1_Code__c = 'CN-99';
		al.Level1_Sys_No__c = '999999';
		insert al;
		Address_Level2__c al2 = new Address_Level2__c();
		al2.Level1_Code__c = 'CN-99';
		al2.Level1_Sys_No__c = '999999';
		al2.Level1_Name__c = '東京';
		al2.Name = '渋谷区';
		al2.Level2_Code__c = 'CN-9999';
		al2.Level2_Sys_No__c = '9999999';
		al2.Address_Level__c = al.id;
		insert al2;
	// 病院を作る
		Account hospital = new Account();
	   
		String rid = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
		hospital.Name = 'test hospital';
		hospital.recordtypeId = rid;
		hospital.Is_Active__c = '有効';
		insert hospital;

		// 戦略科室を得る
		Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
		// 診療科を作る
		Account dep = new Account();
		dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
		dep.Name = 'test dep';
		dep.AgentCode_Ext__c = '9999998';
		dep.ParentId = strategicDep[0].Id;
		dep.Department_Class__c = strategicDep[0].Id;
		dep.Hospital__c = hospital.Id;
		insert dep;
	  

		List<Contact> conList = new List<Contact>();
		Contact con1 = new Contact();
		con1.Firstname='ZZ1';
		con1.LastName = '取引先責任者1';
		con1.RecordTypeId = rtDoc.id;
		con1.AccountId = dep.Id;
		conList.add(con1);

		insert conList;
	RecordType Type = [select id from RecordType where DeveloperName='SI_Oppor'];
	String TypeID = Type.Id;
	Opportunity opp1 = new Opportunity();
		opp1.Name = '引合1';
		opp1.AccountId = dep.Id;
		opp1.Opportunity_Category__c = 'ENT';
		opp1.Trade__c = '外貿';
		opp1.StageName = '引合';
		opp1.CurrencyIsoCode = 'CNY';
		opp1.Close_Forecasted_Date__c = date.today().addMonths(1);
		opp1.CloseDate = date.today().addMonths(1);
		opp1.Competitor__c = 'B';
		opp1.Purchase_Type__c ='SI（手術室案件）';
		opp1.Sales_Root__c = 'OCM直接販売';
		opp1.Hospital__c = hospital.id;
		//opp1.Department_Class__c = accDepClass.id;
		opp1.StageName = '引合';
		opp1.RecordTypeid = TypeID;
	insert opp1;
	
	ISO_DemandOperAndDemonsController iso = new ISO_DemandOperAndDemonsController();
	iso.OpporIdStr = opp1.id;
	IS_Opportunity_Demand__c ISOhead = new IS_Opportunity_Demand__c();
	ISOhead.Opportunity_ID__c = opp1.id;
	ISOhead.Public_Hospital_TF__c = true;
	ISOhead.Preparation_Stage_TF__c = true;
	ISOhead.Operating_Room_Plane_Graph_TF__c = true;
	ISOhead.Demonstration_Area_Plane_Graph_TF__c = true;
	insert ISOhead;
	IS_Opportunity_Demand_Operating__c iso_Odo = new IS_Opportunity_Demand_Operating__c();
	iso_Odo.Dept_Others_TF__c = true;
	iso_Odo.Operating_Room_Position_Area__c = '2333';
	iso_Odo.Equipment_Center_Crtl_Minor_TF__c = true;
	iso_Odo.Compatible_Signal_TF__c  = true;
	iso_Odo.Party_A_Hold_TF__c = true;
	iso_Odo.Purchase_Plan_SpringArm_List__c = '甲方已有';
	iso_Odo.Shadowless_Lamp_Procurement_Plan__c = '甲方已有';
	iso_Odo.Shadowless_Lamp_Procurement_Plan__c = '甲方已有';
	iso_Odo.Side_Camera_Procurement_Plan__c = '甲方已有';
	iso_Odo.IS_Opportunity_Demand__c = ISOhead.id;
	iso_Odo.Operating_Room_Position_Area__c = '';
	iso_Odo.OTV_S190_TF__c = false;

	insert iso_Odo;

	ISO_DemandOperAndDemonsController.SetQuoteDecide(opp1.id);
	ISO_DemandOperAndDemonsController.UpdateMotherOpportunity(new List<IS_Opportunity_Demand__c>(),new List<IS_Opportunity_Demand__c>());
	ISO_DemandOperAndDemonsController.SetStockDate(ISOhead.id);
	ISO_DemandOperAndDemonsController.Abort_SI(ISOhead.id,'error');
	ISO_DemandOperAndDemonsController.CopyFunc(ISOhead.id);
	iso.init();
	iso.ISodcIdStr = ISOhead.id;
	iso.CopyIDStr = ISOhead.id;
	iso.Save();
	iso.CopyIDStr = null;
	iso.UnableToEdit = true;
	iso.save(); 
	}
	
	@isTest static void test_method_Four() {
				// Implement test code
				Profile pf = [select Id from Profile where Id =:system.label.ProfileId_SystemAdmin];
		RecordType rtHP = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'HP'];
		RecordType rtDepClass = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'Department_Class_ENT'];           // 耳鼻喉科
		RecordType rtDep = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'Department_ENT'];
		RecordType rtDoc = [select id from RecordType where IsActive = true and SobjectType = 'Contact' and DeveloperName =:'Doctor'];
		
		Address_Level__c al = new Address_Level__c();
		al.Name = '東京';
		al.Level1_Code__c = 'CN-99';
		al.Level1_Sys_No__c = '999999';
		insert al;
		Address_Level2__c al2 = new Address_Level2__c();
		al2.Level1_Code__c = 'CN-99';
		al2.Level1_Sys_No__c = '999999';
		al2.Level1_Name__c = '東京';
		al2.Name = '渋谷区';
		al2.Level2_Code__c = 'CN-9999';
		al2.Level2_Sys_No__c = '9999999';
		al2.Address_Level__c = al.id;
		insert al2;
	// 病院を作る
		Account hospital = new Account();
	   
		String rid = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
		hospital.Name = 'test hospital';
		hospital.recordtypeId = rid;
		hospital.Is_Active__c = '有効';
		insert hospital;

		// 戦略科室を得る
		Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
		// 診療科を作る
		Account dep = new Account();
		dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
		dep.Name = 'test dep';
		dep.AgentCode_Ext__c = '9999998';
		dep.ParentId = strategicDep[0].Id;
		dep.Department_Class__c = strategicDep[0].Id;
		dep.Hospital__c = hospital.Id;
		insert dep;
	  

		List<Contact> conList = new List<Contact>();
		Contact con1 = new Contact();
		con1.Firstname='ZZ1';
		con1.LastName = '取引先責任者1';
		con1.RecordTypeId = rtDoc.id;
		con1.AccountId = dep.Id;
		conList.add(con1);

		insert conList;
		RecordType Type = [select id from RecordType where DeveloperName='SI_Oppor'];
		String TypeID = Type.Id;
		Opportunity opp1 = new Opportunity();
			opp1.Name = '引合1';
			opp1.AccountId = dep.Id;
			opp1.Opportunity_Category__c = 'ENT';
			opp1.Trade__c = '外貿';
			opp1.StageName = '引合';
			opp1.CurrencyIsoCode = 'CNY';
			opp1.Close_Forecasted_Date__c = date.today().addMonths(1);
			opp1.CloseDate = date.today().addMonths(1);
			opp1.Competitor__c = 'B';
			opp1.Purchase_Type__c ='SI（手術室案件）';
			opp1.Sales_Root__c = 'OCM直接販売';
			opp1.Hospital__c = hospital.id;
			//opp1.Department_Class__c = accDepClass.id;
			opp1.StageName = '引合';
			opp1.RecordTypeid = TypeID;
		insert opp1;
		
		ISO_DemandOperAndDemonsController iso = new ISO_DemandOperAndDemonsController();
		iso.OpporIdStr = opp1.id;
		IS_Opportunity_Demand__c ISOhead = new IS_Opportunity_Demand__c();
		ISOhead.Opportunity_ID__c = opp1.id;
		ISOhead.Public_Hospital_TF__c = true;
		ISOhead.Preparation_Stage_TF__c = true;
		ISOhead.Operating_Room_Plane_Graph_TF__c = true;
		ISOhead.Demonstration_Area_Plane_Graph_TF__c = true;
		insert ISOhead;
		IS_Opportunity_Demand_Operating__c iso_Odo = new IS_Opportunity_Demand_Operating__c();
		iso_Odo.Dept_Others_TF__c = true;
		iso_Odo.Operating_Room_Position_Area__c = '2333';
		iso_Odo.Equipment_Center_Crtl_Minor_TF__c = true;
		iso_Odo.Compatible_Signal_TF__c  = true;
		iso_Odo.Party_A_Hold_TF__c = true;
		iso_Odo.Purchase_Plan_SpringArm_List__c = '甲方已有';
		iso_Odo.Shadowless_Lamp_Procurement_Plan__c = '甲方已有';
		iso_Odo.Shadowless_Lamp_Procurement_Plan__c = '甲方已有';
		iso_Odo.Side_Camera_Procurement_Plan__c = '甲方已有';
		iso_Odo.IS_Opportunity_Demand__c = ISOhead.id;
		iso_Odo.Operating_Room_Position_Area__c = '';
		iso_Odo.OTV_S190_TF__c = false;

		insert iso_Odo;

		ISO_DemandOperAndDemonsController.SetQuoteDecide(opp1.id);
		ISO_DemandOperAndDemonsController.UpdateMotherOpportunity(new List<IS_Opportunity_Demand__c>(),new List<IS_Opportunity_Demand__c>());
		ISO_DemandOperAndDemonsController.SetStockDate(ISOhead.id);
		ISO_DemandOperAndDemonsController.Abort_SI(ISOhead.id,'error');
		ISO_DemandOperAndDemonsController.CopyFunc(ISOhead.id);
		iso.init();
		iso.ISodcIdStr = null;
		iso.Save();
		iso.CopyIDStr = null;
		iso.UnableToEdit = true;
		iso.save(); 
	}
}