@istest
public class LexConsumableControllerTest {
    @IsTest
    static void ConsumableOrdertest1(){
        user MyUser_Test;
        Account myAccount1;
		Account contract;
        User thisUser = [ select Id from User where Id = :UserInfo.getUserId()];
        NoteStay__c n = new NoteStay__c(Name = 'NoteStay',IsStay__c = true);
        insert n;
        System.runAs(thisUser){
			Profile prof1 = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
			List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
			List<RecordType> rectCo1 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'AgencyContract'];

			if (rectCo.size() == 0) {
				return;
			}
			StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
			myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '8888888',Product_Limit_Date__c = 'Test07|3|100,Test08|10|50');
			insert myAccount1;
			contract = new Account(RecordTypeId=rectCo1[0].Id ,Name ='contractName',ParentId = myAccount1.id,Agent_Ref__c =myAccount1.id, Contract_Department_Class__c = 'ET',Contract_Decide_Start_Date__c=Date.today().addDays(-2),
            	Contract_Decide_End_Date__c = Date.today().addDays(2),Dealer_discount__c = 0.8);
       		insert contract;
			Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.id);
			insert core;
			MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof1.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com',Work_Location__c = '重庆');
			insert MyUser_Test;

		}
       
		System.runAs(MyUser_Test){
			//产品数据
			Product2 prod01 = new Product2(Name='Test01',
								ProductCode='Test01',
								Asset_Model_No__c = 'Test01',
								SFDA_Status__c = '有効',
								Product_Status__c = '正常销售',
								SFDA_Approbated_Status__c = '有效',
								Category3__c = 'CDS',
								Category4__c = 'OER',
								Category5__c = '其它',
								Dealer_special_Object__c = true,
								SFDA_Approbation_No__c = 'Test001',
								Packing_list_manual__c = 1,
								SFDA_Expiration_Date__c= Date.today(),
								Intra_Trade_List_RMB_1__c = 1000,
								Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
								Manual_Entry__c = false);

			Product2 prod02 = new Product2(Name='Test02',
								ProductCode='Test02',
								Asset_Model_No__c = 'Test02',
								SFDA_Status__c = '有効',
								Product_Status__c = '正常销售',
								SFDA_Approbated_Status__c = '有效',
								Category3__c = 'ENT',
								Category4__c = 'Celon',
								Category5__c = 'Celon',
								Dealer_special_Object__c = true,
								SFDA_Approbation_No__c = 'Test002',
								Packing_list_manual__c = 1,
								SFDA_Expiration_Date__c= Date.today(),
								Intra_Trade_List_RMB_1__c = 1000,
								Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
								Manual_Entry__c = false);

			Product2 prod03 = new Product2(Name='Test03',
								ProductCode='Test03',
								Asset_Model_No__c = 'Test03',
								SFDA_Status__c = '有効',
								Dealer_special_Object__c = true,
								Product_Status__c = '正常销售',
								SFDA_Approbated_Status__c = '有效',
								Category3__c = 'US',
								Category4__c = 'ALOKA',
								Category5__c = '体外超声',
								Intra_Trade_List_RMB_1__c = 1000,
								Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
								Manual_Entry__c = false);
	        insert new Product2[] {prod01,prod02,prod03};

			//制作产品
			Product2__c proG = new Product2__c(Name='MH-155:白平衡帽',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
			insert proG;
			System.debug('proG:'+proG);
			System.debug('proG1:'+proG.Estimation_Entry_Possibility__c);
			System.debug('prod07:'+prod01);
			System.debug('prod071:'+prod01.Estimation_Entry_Possibility__c);
			Product2__c proH = new Product2__c(Name='MB-677:BNC电缆',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
			insert proH;
			Product2__c proF = new Product2__c(Name='TooMAJ-643R:水囊鞘管003',OT_CODE_Text__c='Test003',Product2__c = prod03.Id);
			insert proF;


			//订单
			Consumable_order__c order = new Consumable_order__c();
			order.Name = 'testMing';
			order.Order_status__c = '批准';
			order.RecordTypeid = System.Label.RT_ConOrder_Order;
			order.Dealer_Info__c = myAccount1.id;
			order.Inventory_date__c = Date.today();
        	order.Order_type__c = '订单';
			order.Order_ProType__c = 'ET';
			order.orderPattern__c = 'agreementorder';
			insert  order;
			Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
			Orderdet.Name = 'OCM_01_00101';
			Orderdet.Consumable_order__c = order.Id;
			Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
			Orderdet.Consumable_Product__c = proG.Id;
			Orderdet.Consumable_count__c = 4;
			insert Orderdet;

			Consumable_order_details2__c createDetail2 = new Consumable_order_details2__c();
			createDetail2 = new Consumable_order_details2__c();
			createDetail2.Consumable_Product__c = proG.id;
			createDetail2.Asset_Model_No__c     = 'Test01';
			createDetail2.Consumable_order_minor__c =  order.id;
			createDetail2.Consumable_Arrived_order__c = order.id;
			createDetail2.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
			createDetail2.Asset_Model_No__c         = proG.Asset_Model_No__c;
			createDetail2.Bar_Code__c = '123';
			createDetail2.Box_Piece__c ='盒';
			createDetail2.Arrive_date__c            = Date.today();

			Oly_TriggerHandler.bypass('ConsumableAssetHander');
			insert createDetail2;

            Test.startTest();
			LexConsumableController.ConsumableorderdetailsInfo c1 = new LexConsumableController.ConsumableorderdetailsInfo(Orderdet);
			ContentVersion v = new ContentVersion();
			LexConsumableController.ConsumableorderdetailsInfo c2 = new LexConsumableController.ConsumableorderdetailsInfo(v);
            LexConsumableController l = new LexConsumableController();
            LexConsumableController.Results re =  LexConsumableController.init('', order.Id, '');
            LexConsumableController.searchConsumableorderdetails(re.userWorkLocation, re.agencyProType, re.accountName, re.accountid, re.hospitalId, re.contractId, 'testMing', '', '', '', re.category_Goods, re.specialCampaign, JSON.serialize(re.dealerProductId), re.methodType, JSON.serialize(re.consumableorderdetailsRecordsview), re.editAble, re.proLimitAndDate);
            LexConsumableController.searchorderdetails(re.methodType, re.accountid, re.hospitalId, re.contractId, re.userWorkLocation, re.accountName, re.proLimitAndDate, re.editAble);
			LexConsumableController.sorder(order.Id,myAccount1.Id);
            Test.stopTest();
        }
    }

	@IsTest
    static void ConsumableOrdertest2(){
        user MyUser_Test;
        Account myAccount1;
		Account contract;
        User thisUser = [ select Id from User where Id = :UserInfo.getUserId()];
        NoteStay__c n = new NoteStay__c(Name = 'NoteStay',IsStay__c = true);
        insert n;
        System.runAs(thisUser){
			Profile prof1 = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
			List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
			List<RecordType> rectCo1 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'AgencyContract'];

			if (rectCo.size() == 0) {
				return;
			}
			StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
			myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '8888888',Product_Limit_Date__c = 'Test07|3|100,Test08|10|50');
			insert myAccount1;
			contract = new Account(RecordTypeId=rectCo1[0].Id ,Name ='contractName',ParentId = myAccount1.id,Agent_Ref__c =myAccount1.id, Contract_Department_Class__c = 'ET',Contract_Decide_Start_Date__c=Date.today().addDays(-2),
            	Contract_Decide_End_Date__c = Date.today().addDays(2),Dealer_discount__c = 0.8);
       		insert contract;

			Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.id);
			insert core;
			MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof1.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com',Work_Location__c = '重庆');
			insert MyUser_Test;

		}
		User MyUser_Test2 = [select Id from User where Id = '00510000000gmxH'];
		System.runAs(MyUser_Test){
		// System.runAs(MyUser_Test2){
		// System.runAs(MyUser_Test){
			//产品数据
			Product2 prod01 = new Product2(Name='Test01',
								ProductCode='Test01',
								Asset_Model_No__c = 'Test01',
								SFDA_Status__c = '有効',
								Product_Status__c = '正常销售',
								SFDA_Approbated_Status__c = '有效',
								Category3__c = 'CDS',
								Category4__c = 'OER',
								Category5__c = '其它',
								Dealer_special_Object__c = true,
								SFDA_Approbation_No__c = 'Test001',
								Packing_list_manual__c = 1,
								SFDA_Expiration_Date__c= Date.today(),
								Intra_Trade_List_RMB_1__c = 1000,
								Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
								Manual_Entry__c = false);

			Product2 prod02 = new Product2(Name='Test02',
								ProductCode='Test02',
								Asset_Model_No__c = 'Test02',
								SFDA_Status__c = '有効',
								Product_Status__c = '正常销售',
								SFDA_Approbated_Status__c = '有效',
								Category3__c = 'ENT',
								Category4__c = 'Celon',
								Category5__c = 'Celon',
								Dealer_special_Object__c = true,
								SFDA_Approbation_No__c = 'Test002',
								Packing_list_manual__c = 1,
								SFDA_Expiration_Date__c= Date.today(),
								Intra_Trade_List_RMB_1__c = 1000,
								Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
								Manual_Entry__c = false);

			Product2 prod03 = new Product2(Name='Test03',
								ProductCode='Test03',
								Asset_Model_No__c = 'Test03',
								SFDA_Status__c = '有効',
								Dealer_special_Object__c = true,
								Product_Status__c = '正常销售',
								SFDA_Approbated_Status__c = '有效',
								Category3__c = 'US',
								Category4__c = 'ALOKA',
								Category5__c = '体外超声',
								Intra_Trade_List_RMB_1__c = 1000,
								Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
								Manual_Entry__c = false);
	        insert new Product2[] {prod01,prod02,prod03};

			//制作产品
			Product2__c proG = new Product2__c(Name='MH-155:白平衡帽',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
			insert proG;
			System.debug('proG:'+proG);
			System.debug('proG1:'+proG.Estimation_Entry_Possibility__c);
			System.debug('prod07:'+prod01);
			System.debug('prod071:'+prod01.Estimation_Entry_Possibility__c);
			Product2__c proH = new Product2__c(Name='MB-677:BNC电缆',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
			insert proH;
			Product2__c proF = new Product2__c(Name='TooMAJ-643R:水囊鞘管003',OT_CODE_Text__c='Test003',Product2__c = prod03.Id);
			insert proF;

			//创建医院
			Account hospital = new Account();
			hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
			hospital.Name = 'test hospital';
			hospital.Is_Active__c = '有効';
			hospital.Attribute_Type__c = '卫生部';
			hospital.Speciality_Type__c = '综合医院';
			hospital.Grade__c = '一级';
			hospital.OCM_Category__c = 'SLTV';
			hospital.Is_Medical__c = '医疗机构';
			hospital.Town__c = '东京';
			insert hospital;

			//建一条医院特价产品
			hospitalprice__c hc = new hospitalprice__c();
			hc.hospital__c = hospital.Id;
			hc.product__c = proG.Id;
			hc.aph__c = '12332';
			hc.account__c = myAccount1.Id;
			insert hc;

			//医院
			Consumable_order__c order1 = new Consumable_order__c();
			order1.Name = 'testMing1';
			order1.Order_status__c = '批准';
			order1.RecordTypeid = System.Label.RT_ConOrder_Order;
			order1.Dealer_Info__c = myAccount1.id;
			order1.Inventory_date__c = Date.today();
        	order1.Order_type__c = '订单';
			order1.Order_ProType__c = 'ET';
			order1.orderPattern__c = 'hospitalorder';
			insert  order1;
			Consumable_orderdetails__c Orderdet1 = new Consumable_orderdetails__c();
			Orderdet1.Name = 'OCM_01_00102';
			Orderdet1.Consumable_order__c = order1.Id;
			Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
			Orderdet1.Consumable_Product__c = proG.Id;
			Orderdet1.Consumable_count__c = 4;
			insert Orderdet1;

			Consumable_order_details2__c createDetail3 = new Consumable_order_details2__c();
			createDetail3 = new Consumable_order_details2__c();
			createDetail3.Consumable_Product__c = proG.id;
			createDetail3.Asset_Model_No__c     = 'Test02';
			createDetail3.Consumable_order_minor__c =  order1.id;
			createDetail3.Consumable_Arrived_order__c = order1.id;
			createDetail3.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
			createDetail3.Asset_Model_No__c         = proG.Asset_Model_No__c;
			createDetail3.Bar_Code__c = '123';
			createDetail3.Box_Piece__c ='盒';
			createDetail3.Arrive_date__c            = Date.today();

			Oly_TriggerHandler.bypass('ConsumableAssetHander');
			insert createDetail3;

            Test.startTest();
            LexConsumableController.Results re =  LexConsumableController.init('', order1.Id, '');
			LexConsumableController.searchConsumableorderdetails(re.userWorkLocation, re.agencyProType, re.accountName, re.accountid, re.hospitalId, re.contractId, 'testMing', '', '', '', re.category_Goods, re.specialCampaign, JSON.serialize(re.dealerProductId), re.methodType, JSON.serialize(re.consumableorderdetailsRecordsview), re.editAble, re.proLimitAndDate);
            LexConsumableController.searchorderdetails(re.methodType, re.accountid, re.hospitalId, re.contractId, re.userWorkLocation, re.accountName, re.proLimitAndDate, re.editAble);
			LexConsumableController.searchConsumableorderdetails(re.userWorkLocation, re.agencyProType, re.accountName, re.accountid, hospital.Id, contract.Id, 'testMing', '', '', '', re.category_Goods, re.specialCampaign, JSON.serialize(re.dealerProductId), re.methodType, JSON.serialize(re.consumableorderdetailsRecordsview), re.editAble, re.proLimitAndDate);
            LexConsumableController.searchorderdetails(re.methodType, re.accountid, hospital.Id, contract.Id, re.userWorkLocation, re.accountName, re.proLimitAndDate, re.editAble);
            Test.stopTest();
        }
    }

	@IsTest
    static void ConsumableOrdertest3(){
        user MyUser_Test;
        Account myAccount1;
		Account contract;
		Consumable_order__c order2;
        User thisUser = [ select Id from User where Id = :UserInfo.getUserId()];
        NoteStay__c n = new NoteStay__c(Name = 'NoteStay',IsStay__c = true);
        insert n;
        System.runAs(thisUser){
			Profile prof1 = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
			List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
			List<RecordType> rectCo1 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'AgencyContract'];

			if (rectCo.size() == 0) {
				return;
			}
			StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
			myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '8888888',Product_Limit_Date__c = 'Test07|3|100,Test08|10|50');
			insert myAccount1;
			contract = new Account(RecordTypeId=rectCo1[0].Id ,Name ='contractName',ParentId = myAccount1.id,Agent_Ref__c =myAccount1.id, Contract_Department_Class__c = 'ET',Contract_Decide_Start_Date__c=Date.today().addDays(-2),
            	Contract_Decide_End_Date__c = Date.today().addDays(2),Dealer_discount__c = 0.8);
       		insert contract;
			Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.id);
			insert core;
			MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof1.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com',Work_Location__c = '重庆');
			insert MyUser_Test;

			//产品数据
			Product2 prod01 = new Product2(Name='Test01',
								ProductCode='Test01',
								Asset_Model_No__c = 'Test01',
								SFDA_Status__c = '有効',
								Product_Status__c = '正常销售',
								SFDA_Approbated_Status__c = '有效',
								Category3__c = 'CDS',
								Category4__c = 'OER',
								Category5__c = '其它',
								Dealer_special_Object__c = true,
								SFDA_Approbation_No__c = 'Test001',
								Packing_list_manual__c = 1,
								SFDA_Expiration_Date__c= Date.today(),
								Intra_Trade_List_RMB_1__c = 1000,
								Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
								Manual_Entry__c = false);
	
			Product2 prod02 = new Product2(Name='Test02',
								ProductCode='Test02',
								Asset_Model_No__c = 'Test02',
								SFDA_Status__c = '有効',
								Product_Status__c = '正常销售',
								SFDA_Approbated_Status__c = '有效',
								Category3__c = 'ENT',
								Category4__c = 'Celon',
								Category5__c = 'Celon',
								Dealer_special_Object__c = true,
								SFDA_Approbation_No__c = 'Test002',
								Packing_list_manual__c = 1,
								SFDA_Expiration_Date__c= Date.today(),
								Intra_Trade_List_RMB_1__c = 1000,
								Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
								Manual_Entry__c = false);
	
			Product2 prod03 = new Product2(Name='Test03',
								ProductCode='Test03',
								Asset_Model_No__c = 'Test03',
								SFDA_Status__c = '有効',
								Dealer_special_Object__c = true,
								Product_Status__c = '正常销售',
								SFDA_Approbated_Status__c = '有效',
								Category3__c = 'US',
								Category4__c = 'ALOKA',
								Category5__c = '体外超声',
								Intra_Trade_List_RMB_1__c = 1000,
								Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
								Manual_Entry__c = false);
			insert new Product2[] {prod01,prod02,prod03};
	
			//制作产品
			Product2__c proG = new Product2__c(Name='MH-155:白平衡帽',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
			insert proG;
			System.debug('proG:'+proG);
			System.debug('proG1:'+proG.Estimation_Entry_Possibility__c);
			System.debug('prod07:'+prod01);
			System.debug('prod071:'+prod01.Estimation_Entry_Possibility__c);
			Product2__c proH = new Product2__c(Name='MB-677:BNC电缆',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
			insert proH;
			Product2__c proF = new Product2__c(Name='TooMAJ-643R:水囊鞘管003',OT_CODE_Text__c='Test003',Product2__c = prod03.Id);
			insert proF;
	
			Dealer_Product__c dpc = new Dealer_Product__c();
			dpc.Dealer_Contact__c = contract.id;
			dpc.Dealer_Product2__c = proG.id;
			dpc.Special_Discount__c = 45;
			dpc.Campaign_StartDate__c = Date.today().addDays(-1);
			dpc.Campaign_EndDate__c = Date.today().addDays(1);
			insert dpc;
			
			Dealer_Product__c dpc2 = new Dealer_Product__c();
			dpc2.Dealer_Contact__c = contract.id;
			dpc2.Dealer_Product2__c = proG.id;
			dpc2.Special_Campaign_Price__c = 4500;
			insert dpc2;
			
			Dealer_Product__c dpc1 = new Dealer_Product__c();
			dpc1.Dealer_Contact__c = contract.id;
			dpc1.Dealer_Product2__c = proH.id;
			dpc1.Special_Campaign_Price__c = 23456;
			insert dpc1;
			//促销
			order2 = new Consumable_order__c();
			order2.Name = 'testMing2';
			order2.Order_status__c = '批准';
			order2.RecordTypeid = System.Label.RT_ConOrder_Order;
			order2.Dealer_Info__c = myAccount1.id;
			order2.Inventory_date__c = Date.today();
			order2.Order_type__c = '订单';
			order2.Order_ProType__c = 'ET';
			order2.orderPattern__c = 'promotionorder';
			insert  order2;
			Consumable_orderdetails__c Orderdet2 = new Consumable_orderdetails__c();
			Orderdet2.Name = 'OCM_01_00103';
			Orderdet2.Consumable_order__c = order2.Id;
			Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
			Orderdet2.Consumable_Product__c = proG.Id;
			Orderdet2.Consumable_count__c = 4;
			insert Orderdet2;
	
			Consumable_order_details2__c createDetail4 = new Consumable_order_details2__c();
			createDetail4 = new Consumable_order_details2__c();
			createDetail4.Consumable_Product__c = proG.id;
			createDetail4.Asset_Model_No__c     = 'Test03';
			createDetail4.Consumable_order_minor__c =  order2.id;
			createDetail4.Consumable_Arrived_order__c = order2.id;
			createDetail4.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
			createDetail4.Asset_Model_No__c         = proG.Asset_Model_No__c;
			createDetail4.Bar_Code__c = '123';
			createDetail4.Box_Piece__c ='盒';
			createDetail4.Arrive_date__c            = Date.today();
			Oly_TriggerHandler.bypass('ConsumableAssetHander');
			insert createDetail4;
		}
       
		System.runAs(MyUser_Test){

            Test.startTest();
			LexConsumableController.Results re =  LexConsumableController.init('', order2.Id, '');
			LexConsumableController.searchConsumableorderdetails(re.userWorkLocation, re.agencyProType, re.accountName, re.accountid, re.hospitalId, re.contractId, 'testMing', '', '', '', re.category_Goods, re.specialCampaign, JSON.serialize(re.dealerProductId), re.methodType, JSON.serialize(re.consumableorderdetailsRecordsview), re.editAble, re.proLimitAndDate);
            LexConsumableController.searchorderdetails(re.methodType, re.accountid, re.hospitalId, re.contractId, re.userWorkLocation, re.accountName, re.proLimitAndDate, re.editAble);
			LexConsumableController.searchConsumableorderdetails(re.userWorkLocation, re.agencyProType, re.accountName, re.accountid, re.hospitalId, contract.Id, 'testMing', '', '', '', re.category_Goods, re.specialCampaign, JSON.serialize(re.dealerProductId), re.methodType, JSON.serialize(re.consumableorderdetailsRecordsview), re.editAble, re.proLimitAndDate);
            LexConsumableController.searchorderdetails(re.methodType, re.accountid, re.hospitalId, contract.Id, re.userWorkLocation, re.accountName, re.proLimitAndDate, re.editAble);
            Test.stopTest();
        }
    }

	@IsTest
    static void ConsumableOrdertest4(){
        user MyUser_Test;
        Account myAccount1;
		Account contract;
        User thisUser = [ select Id from User where Id = :UserInfo.getUserId()];
        NoteStay__c n = new NoteStay__c(Name = 'NoteStay',IsStay__c = true);
        insert n;
        System.runAs(thisUser){
			Profile prof1 = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
			List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
			List<RecordType> rectCo1 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'AgencyContract'];
			if (rectCo.size() == 0) {
				return;
			}
			StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
			
			RecordType rectCoO = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
			Account olympus = new Account(RecordTypeId = rectCoO.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
			insert olympus;
			myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '8888888',Product_Limit_Date__c = 'Test07|3|100,Test08|10|50');
			insert myAccount1;
			System.debug('account111:'+myAccount1);
			contract = new Account(RecordTypeId=rectCo1[0].Id ,Name ='contractName',ParentId = myAccount1.id,Agent_Ref__c =myAccount1.id, Contract_Department_Class__c = 'ET',Contract_Decide_Start_Date__c=Date.today().addDays(-2),
            	Contract_Decide_End_Date__c = Date.today().addDays(2),ET_SP_Dealer__c = true);
			insert contract;
			System.debug('account111:'+contract);
			Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.id);
			insert core;
			MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof1.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com',Work_Location__c = '重庆');
			insert MyUser_Test;

		}
       
		System.runAs(MyUser_Test){
			//产品数据
			Product2 prod01 = new Product2(Name='Test01',
								ProductCode='Test01',
								Asset_Model_No__c = 'Test01',
								SFDA_Status__c = '有効',
								Product_Status__c = '正常销售',
								SFDA_Approbated_Status__c = '有效',
								Category3__c = 'CDS',
								Category4__c = 'OER',
								Category5__c = '其它',
								Dealer_special_Object__c = true,
								SFDA_Approbation_No__c = 'Test001',
								Packing_list_manual__c = 1,
								SFDA_Expiration_Date__c= Date.today(),
								Intra_Trade_List_RMB_1__c = 1000,
								Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
								Manual_Entry__c = false);

			Product2 prod02 = new Product2(Name='Test02',
								ProductCode='Test02',
								Asset_Model_No__c = 'Test02',
								SFDA_Status__c = '有効',
								Product_Status__c = '正常销售',
								SFDA_Approbated_Status__c = '有效',
								Category3__c = 'ENT',
								Category4__c = 'Celon',
								Category5__c = 'Celon',
								Dealer_special_Object__c = true,
								SFDA_Approbation_No__c = 'Test002',
								Packing_list_manual__c = 1,
								SFDA_Expiration_Date__c= Date.today(),
								Intra_Trade_List_RMB_1__c = 1000,
								Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
								Manual_Entry__c = false);

			Product2 prod03 = new Product2(Name='Test03',
								ProductCode='Test03',
								Asset_Model_No__c = 'Test03',
								SFDA_Status__c = '有効',
								Dealer_special_Object__c = true,
								Product_Status__c = '正常销售',
								SFDA_Approbated_Status__c = '有效',
								Category3__c = 'US',
								Category4__c = 'ALOKA',
								Category5__c = '体外超声',
								Intra_Trade_List_RMB_1__c = 1000,
								Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
								Manual_Entry__c = false);
	        insert new Product2[] {prod01,prod02,prod03};

			//制作产品
			Product2__c proG = new Product2__c(Name='MH-155:白平衡帽',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
			insert proG;
			System.debug('proG:'+proG);
			System.debug('proG1:'+proG.Estimation_Entry_Possibility__c);
			System.debug('prod07:'+prod01);
			System.debug('prod071:'+prod01.Estimation_Entry_Possibility__c);
			Product2__c proH = new Product2__c(Name='MB-677:BNC电缆',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
			insert proH;
			Product2__c proF = new Product2__c(Name='TooMAJ-643R:水囊鞘管003',OT_CODE_Text__c='Test003',Product2__c = prod03.Id);
			insert proF;


			//订单
			Consumable_order__c order = new Consumable_order__c();
			order.Name = 'testMing';
			order.Order_status__c = '批准';
			order.RecordTypeid = System.Label.RT_ConOrder_Order;
			order.Dealer_Info__c = myAccount1.id;
			order.Inventory_date__c = Date.today();
        	order.Order_type__c = '订单';
			order.Order_ProType__c = 'ET';
			order.orderPattern__c = 'agreementorder';
			insert  order;
			Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
			Orderdet.Name = 'OCM_01_00101';
			Orderdet.Consumable_order__c = order.Id;
			Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
			Orderdet.Consumable_Product__c = proG.Id;
			Orderdet.Consumable_count__c = 4;
			insert Orderdet;

			Consumable_order_details2__c createDetail2 = new Consumable_order_details2__c();
			createDetail2 = new Consumable_order_details2__c();
			createDetail2.Consumable_Product__c = proG.id;
			createDetail2.Asset_Model_No__c     = 'Test01';
			createDetail2.Consumable_order_minor__c =  order.id;
			createDetail2.Consumable_Arrived_order__c = order.id;
			createDetail2.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
			createDetail2.Asset_Model_No__c         = proG.Asset_Model_No__c;
			createDetail2.Bar_Code__c = '123';
			createDetail2.Box_Piece__c ='盒';
			createDetail2.Arrive_date__c            = Date.today();

			Oly_TriggerHandler.bypass('ConsumableAssetHander');
			insert createDetail2;

            Test.startTest();
            LexConsumableController.Results re =  LexConsumableController.init('agreementorder', '', '');
			re.consumableorderdetailsRecordsview[0].check = true;
			re.consumableorderdetailsRecordsview[0].esd.Consumable_count__c = 1;
			String conId = contract.Id;
			LexConsumableController.ordrCopy(contract.Name,JSON.serialize(re.coc),re.agencyProType,re.accountid,JSON.serialize(re.consumableorderdetailsRecordsview),JSON.serialize(re.contactDealer),re.methodType,'',conId,re.agencyProType1,false);
			LexConsumableController.save('',JSON.serialize(re.coc),re.agencyProType,re.accountid,JSON.serialize(re.consumableorderdetailsRecordsview),JSON.serialize(re.contactDealer),re.methodType,re.ESetId,'',conId,re.agencyProType1,false);
			LexConsumableController.save(contract.Name,JSON.serialize(re.coc),re.agencyProType,re.accountid,JSON.serialize(re.consumableorderdetailsRecordsview),JSON.serialize(re.contactDealer),re.methodType,re.ESetId,'','',re.agencyProType1,false);
			LexConsumableController.save(':Testaccount001',JSON.serialize(re.coc),'ET',re.accountid,JSON.serialize(re.consumableorderdetailsRecordsview),JSON.serialize(re.contactDealer),re.methodType,re.ESetId,'',re.contractId,'ET',false);
			LexConsumableController.save(':Testaccount001',JSON.serialize(re.coc),'ET',re.accountid,JSON.serialize(re.consumableorderdetailsRecordsview),JSON.serialize(re.contactDealer),'agreementorder',re.ESetId,'',re.contractId,'ET',false);
			LexConsumableController.save(':Testaccount001',JSON.serialize(re.coc),'ET',re.accountid,JSON.serialize(re.consumableorderdetailsRecordsview),JSON.serialize(re.contactDealer),'promotionorder',re.ESetId,'',re.contractId,'ET',false);
			LexConsumableController.save(':Testaccount001',JSON.serialize(re.coc),'ET',re.accountid,JSON.serialize(re.consumableorderdetailsRecordsview),JSON.serialize(re.contactDealer),'hospitalorder',re.ESetId,'',re.contractId,'ET',false);
			Test.stopTest();
        }
    }

	@IsTest
    static void ConsumableOrdertest5(){
		user MyUser_Test;
        Account myAccount1;
        User thisUser = [ select Id from User where Id = :UserInfo.getUserId()];
        NoteStay__c n = new NoteStay__c(Name = 'NoteStay',IsStay__c = true);
		ContentVersion cv;
		Consumable_order__c order;
        insert n;
        System.runAs(thisUser){
			Profile prof1 = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
			List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
			if (rectCo.size() == 0) {
				return;
			}
			StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
			RecordType rectCoO = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
			Account olympus = new Account(RecordTypeId = rectCoO.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
			insert olympus;
			myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '8888888',Product_Limit_Date__c = 'Test07|3|100,Test08|10|50');
			insert myAccount1;
			Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.id);
			insert core;
			MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof1.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com',Work_Location__c = '重庆');
			insert MyUser_Test;

			order = new Consumable_order__c();
			order.Name = 'testMing';
			order.Order_status__c = '批准';
			order.RecordTypeid = System.Label.RT_ConOrder_Order;
			order.Dealer_Info__c = myAccount1.id;
			order.Inventory_date__c = Date.today();
        	order.Order_type__c = '订单';
			order.Order_ProType__c = 'ET';
			order.orderPattern__c = 'agreementorder';
			insert  order;

			cv = new ContentVersion();
            cv.Title = 'test.txt';
            cv.PathOnClient = '/' + 'test.txt';
            cv.FirstPublishLocationId = order.Id;
            cv.VersionData = EncodingUtil.base64Decode('VGVzdA==');
            cv.IsMajorVersion = true;
            insert cv;

		}
		System.runAs(MyUser_Test){
			Product2 prod01 = new Product2(Name='Test01',
								ProductCode='Test01',
								Asset_Model_No__c = 'Test01',
								SFDA_Status__c = '有効',
								Product_Status__c = '正常销售',
								SFDA_Approbated_Status__c = '有效',
								Category3__c = 'CDS',
								Category4__c = 'OER',
								Category5__c = '其它',
								Dealer_special_Object__c = true,
								SFDA_Approbation_No__c = 'Test001',
								Packing_list_manual__c = 1,
								SFDA_Expiration_Date__c= Date.today(),
								Intra_Trade_List_RMB_1__c = 1000,
								Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
								Manual_Entry__c = false
								);

			Product2 prod02 = new Product2(Name='Test02',
								ProductCode='Test02',
								Asset_Model_No__c = 'Test02',
								SFDA_Status__c = '有効',
								Product_Status__c = '正常销售',
								SFDA_Approbated_Status__c = '有效',
								Category3__c = 'CDS',
								Category4__c = 'OER',
								Category5__c = 'Celon',
								Dealer_special_Object__c = true,
								SFDA_Approbation_No__c = 'Test002',
								Packing_list_manual__c = 1,
								SFDA_Expiration_Date__c= Date.today(),
								Intra_Trade_List_RMB_1__c = 1000,
								Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
								Manual_Entry__c = false
								);

			Product2 prod03 = new Product2(Name='Test03',
								ProductCode='Test03',
								Asset_Model_No__c = 'Test03',
								SFDA_Status__c = '有効',
								Dealer_special_Object__c = true,
								Product_Status__c = '正常销售',
								SFDA_Approbated_Status__c = '有效',
								Category3__c = 'US',
								Category4__c = 'ALOKA',
								Category5__c = '体外超声',
								Intra_Trade_List_RMB_1__c = 1000,
								Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
								Manual_Entry__c = false);

			Product2 prod04 = new Product2(Name='Test04',
				ProductCode='Test04',Asset_Model_No__c = 'Test04',
								SFDA_Status__c = '有効',
								Dealer_special_Object__c = true,
								Product_Status__c = '正常销售',
								SFDA_Approbated_Status__c = '有效',
								Category3__c = 'OCS',
								Category4__c = '附属品',
								Category5__c = 'OCS',
								Intra_Trade_List_RMB_1__c = 1000,
								Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
								Manual_Entry__c = false);
			Product2 prod05 = new Product2(Name='Test05',
								ProductCode='Test05',
								Asset_Model_No__c = 'Test05',
								SFDA_Status__c = '有効',
								Dealer_special_Object__c = true,
								Product_Status__c = '正常销售',
								SFDA_Approbated_Status__c = '有效',
								Category3__c = '光源',
								Category4__c = 'CLV',
								Category5__c = 'S45',
								Intra_Trade_List_RMB_1__c = 1000,
								Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
								Manual_Entry__c = false);
			insert new Product2[] {prod01,prod02,prod03, prod04, prod05};
			Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
			Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
			Product2__c pro3 = new Product2__c(Name='Pro003',OT_CODE_Text__c='Test003',Product2__c = prod03.Id);
			Product2__c pro4 = new Product2__c(Name='Pro004',OT_CODE_Text__c='Test004',Product2__c = prod04.Id);
			Product2__c pro5 = new Product2__c(Name='Pro005',OT_CODE_Text__c='Test005',Product2__c = prod05.Id);
			insert new Product2__c[] {pro1,pro2,pro3,pro4, pro5};

			

			Test.startTest();
            LexConsumableController.Results re1 =  LexConsumableController.categoryAllload('ET','CDS');
            LexConsumableController.Results re2 =  LexConsumableController.categoryAllload('ENG','CDS');
			LexConsumableController.Results re3 =  LexConsumableController.categoryAllload('','CDS');
			LexConsumableController.Results re4 =  LexConsumableController.categoryload('ET','CDS','OER');
            LexConsumableController.Results re5 =  LexConsumableController.categoryload('ENG','CDS','OER');
			LexConsumableController.Results re6 =  LexConsumableController.categoryload('','CDS','OER');
			String pid = order.Id;
			LexConsumableController.filesUpload(pid,'tset.txt','VGVzdA==');
			LexConsumableController.deleteAtt(cv.Id, pid);
			LexConsumableController.backOrder(pid);
			LexConsumableController.setEditAble(pid);
			LexConsumableController.delConsumable(pid);
			LexConsumableController.OffersPrice();
            Test.stopTest();
		}
	}

	// @IsTest
    // static void ConsumableOrderhospitalorder(){
    //     user MyUser_Test;
    //     Account myAccount1;
	// 	Account contract;
    //     User thisUser = [ select Id from User where Id = :UserInfo.getUserId()];
    //     NoteStay__c n = new NoteStay__c(Name = 'NoteStay',IsStay__c = true);
    //     insert n;
    //     System.runAs(thisUser){
	// 		Profile prof1 = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
	// 		List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
	// 		List<RecordType> rectCo1 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'AgencyContract'];

	// 		if (rectCo.size() == 0) {
	// 			return;
	// 		}
	// 		StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
	// 		myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '8888888',Product_Limit_Date__c = 'Test07|3|100,Test08|10|50');
	// 		insert myAccount1;
	// 		contract = new Account(RecordTypeId=rectCo1[0].Id ,Name ='contractName',ParentId = myAccount1.id,Agent_Ref__c =myAccount1.id, Contract_Department_Class__c = 'ET',Contract_Decide_Start_Date__c=Date.today().addDays(-2),
    //         	Contract_Decide_End_Date__c = Date.today().addDays(2),Dealer_discount__c = 0.8);
    //    		insert contract;

	// 		Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.id);
	// 		insert core;
	// 		MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof1.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com',Work_Location__c = '重庆');
	// 		insert MyUser_Test;

	// 	}
	// 	User MyUser_Test2 = [select Id from User where Id = '00510000000gmxH'];
	// 	// System.runAs(MyUser_Test){
	// 	// System.runAs(MyUser_Test2){
	// 	System.runAs(MyUser_Test){
	// 		//产品数据
	// 		Product2 prod01 = new Product2(Name='Test01',
	// 							ProductCode='Test01',
	// 							Asset_Model_No__c = 'Test01',
	// 							SFDA_Status__c = '有効',
	// 							Product_Status__c = '正常销售',
	// 							SFDA_Approbated_Status__c = '有效',
	// 							Category3__c = 'CDS',
	// 							Category4__c = 'OER',
	// 							Category5__c = '其它',
	// 							Dealer_special_Object__c = true,
	// 							SFDA_Approbation_No__c = 'Test001',
	// 							Packing_list_manual__c = 1,
	// 							SFDA_Expiration_Date__c= Date.today(),
	// 							Intra_Trade_List_RMB_1__c = 1000,
	// 							Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
	// 							Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
	// 							Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
	// 							Manual_Entry__c = false);

	// 		Product2 prod02 = new Product2(Name='Test02',
	// 							ProductCode='Test02',
	// 							Asset_Model_No__c = 'Test02',
	// 							SFDA_Status__c = '有効',
	// 							Product_Status__c = '正常销售',
	// 							SFDA_Approbated_Status__c = '有效',
	// 							Category3__c = 'ENT',
	// 							Category4__c = 'Celon',
	// 							Category5__c = 'Celon',
	// 							Dealer_special_Object__c = true,
	// 							SFDA_Approbation_No__c = 'Test002',
	// 							Packing_list_manual__c = 1,
	// 							SFDA_Expiration_Date__c= Date.today(),
	// 							Intra_Trade_List_RMB_1__c = 1000,
	// 							Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
	// 							Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
	// 							Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
	// 							Manual_Entry__c = false);

	// 		Product2 prod03 = new Product2(Name='Test03',
	// 							ProductCode='Test03',
	// 							Asset_Model_No__c = 'Test03',
	// 							SFDA_Status__c = '有効',
	// 							Dealer_special_Object__c = true,
	// 							Product_Status__c = '正常销售',
	// 							SFDA_Approbated_Status__c = '有效',
	// 							Category3__c = 'US',
	// 							Category4__c = 'ALOKA',
	// 							Category5__c = '体外超声',
	// 							Intra_Trade_List_RMB_1__c = 1000,
	// 							Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
	// 							Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
	// 							Manual_Entry__c = false);
	//         insert new Product2[] {prod01,prod02,prod03};

	// 		//制作产品
	// 		Product2__c proG = new Product2__c(Name='MH-155:白平衡帽',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
	// 		insert proG;
	// 		System.debug('proG:'+proG);
	// 		System.debug('proG1:'+proG.Estimation_Entry_Possibility__c);
	// 		System.debug('prod07:'+prod01);
	// 		System.debug('prod071:'+prod01.Estimation_Entry_Possibility__c);
	// 		Product2__c proH = new Product2__c(Name='MB-677:BNC电缆',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
	// 		insert proH;
	// 		Product2__c proF = new Product2__c(Name='TooMAJ-643R:水囊鞘管003',OT_CODE_Text__c='Test003',Product2__c = prod03.Id);
	// 		insert proF;

	// 		//创建医院
	// 		Account hospital = new Account();
	// 		hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
	// 		hospital.Name = 'test hospital';
	// 		hospital.Is_Active__c = '有効';
	// 		hospital.Attribute_Type__c = '卫生部';
	// 		hospital.Speciality_Type__c = '综合医院';
	// 		hospital.Grade__c = '一级';
	// 		hospital.OCM_Category__c = 'SLTV';
	// 		hospital.Is_Medical__c = '医疗机构';
	// 		hospital.Town__c = '东京';
	// 		insert hospital;

	// 		//建一条医院特价产品
	// 		hospitalprice__c hc = new hospitalprice__c();
	// 		hc.hospital__c = hospital.Id;
	// 		hc.product__c = proG.Id;
	// 		hc.aph__c = '12332';
	// 		hc.account__c = myAccount1.Id;
	// 		insert hc;

	// 		//医院
	// 		Consumable_order__c order1 = new Consumable_order__c();
	// 		order1.Name = 'testMing1';
	// 		order1.Order_status__c = '批准';
	// 		order1.RecordTypeid = System.Label.RT_ConOrder_Order;
	// 		order1.Dealer_Info__c = myAccount1.id;
	// 		order1.Inventory_date__c = Date.today();
    //     	order1.Order_type__c = '订单';
	// 		order1.Order_ProType__c = 'ET';
	// 		order1.orderPattern__c = 'hospitalorder';
	// 		insert  order1;
	// 		Consumable_orderdetails__c Orderdet1 = new Consumable_orderdetails__c();
	// 		Orderdet1.Name = 'OCM_01_00102';
	// 		Orderdet1.Consumable_order__c = order1.Id;
	// 		Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
	// 		Orderdet1.Consumable_Product__c = proG.Id;
	// 		Orderdet1.Consumable_count__c = 4;
	// 		insert Orderdet1;

	// 		Consumable_order_details2__c createDetail3 = new Consumable_order_details2__c();
	// 		createDetail3 = new Consumable_order_details2__c();
	// 		createDetail3.Consumable_Product__c = proG.id;
	// 		createDetail3.Asset_Model_No__c     = 'Test02';
	// 		createDetail3.Consumable_order_minor__c =  order1.id;
	// 		createDetail3.Consumable_Arrived_order__c = order1.id;
	// 		createDetail3.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
	// 		createDetail3.Asset_Model_No__c         = proG.Asset_Model_No__c;
	// 		createDetail3.Bar_Code__c = '123';
	// 		createDetail3.Box_Piece__c ='盒';
	// 		createDetail3.Arrive_date__c            = Date.today();

	// 		Oly_TriggerHandler.bypass('ConsumableAssetHander');
	// 		insert createDetail3;

    //         Test.startTest();
	// 		LexConsumableController.ConsumableorderdetailsInfo c1 = new LexConsumableController.ConsumableorderdetailsInfo(Orderdet1);
	// 		ContentVersion v = new ContentVersion();
	// 		LexConsumableController.ConsumableorderdetailsInfo c2 = new LexConsumableController.ConsumableorderdetailsInfo(v);
    //         LexConsumableController l = new LexConsumableController();
    //         LexConsumableController.Results re =  LexConsumableController.init('hospitalorder', '', '');
	// 		re.consumableorderdetailsRecordsview[0].check = true;
	// 		re.consumableorderdetailsRecordsview[0].esd.Consumable_count__c = 1;
	// 		String conId = contract.Id;
	// 		LexConsumableController.ordrCopy(contract.Name,JSON.serialize(re.coc),re.agencyProType,re.accountid,JSON.serialize(re.consumableorderdetailsRecordsview),JSON.serialize(re.contactDealer),re.methodType,'',conId,re.agencyProType1,false);
	// 		LexConsumableController.save('',JSON.serialize(re.coc),re.agencyProType,re.accountid,JSON.serialize(re.consumableorderdetailsRecordsview),JSON.serialize(re.contactDealer),re.methodType,re.ESetId,'',conId,re.agencyProType1,false);
	// 		LexConsumableController.save(contract.Name,JSON.serialize(re.coc),re.agencyProType,re.accountid,JSON.serialize(re.consumableorderdetailsRecordsview),JSON.serialize(re.contactDealer),re.methodType,re.ESetId,'','',re.agencyProType1,false);
	// 		LexConsumableController.save(':Testaccount001',JSON.serialize(re.coc),'ET',re.accountid,JSON.serialize(re.consumableorderdetailsRecordsview),JSON.serialize(re.contactDealer),re.methodType,re.ESetId,'',re.contractId,'ET',false);
	// 		LexConsumableController.save(':Testaccount001',JSON.serialize(re.coc),'ET',re.accountid,JSON.serialize(re.consumableorderdetailsRecordsview),JSON.serialize(re.contactDealer),'agreementorder',re.ESetId,'',re.contractId,'ET',false);
	// 		LexConsumableController.save(':Testaccount001',JSON.serialize(re.coc),'ET',re.accountid,JSON.serialize(re.consumableorderdetailsRecordsview),JSON.serialize(re.contactDealer),'promotionorder',re.ESetId,'',re.contractId,'ET',false);
	// 		LexConsumableController.save(':Testaccount001',JSON.serialize(re.coc),'ET',re.accountid,JSON.serialize(re.consumableorderdetailsRecordsview),JSON.serialize(re.contactDealer),'hospitalorder',re.ESetId,'',re.contractId,'ET',false);
    //         Test.stopTest();
    //     }
    // }

	@IsTest
    static void ConsumableOrderhospitalorder2(){
        user MyUser_Test;
        Account myAccount1;
		Account contract;
        User thisUser = [ select Id from User where Id = :UserInfo.getUserId()];
        NoteStay__c n = new NoteStay__c(Name = 'NoteStay',IsStay__c = true);
        insert n;
        System.runAs(thisUser){
			Profile prof1 = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
			List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
			List<RecordType> rectCo1 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'AgencyContract'];

			if (rectCo.size() == 0) {
				return;
			}
			StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
			myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '8888888',Product_Limit_Date__c = 'Test07|3|100,Test08|10|50');
			insert myAccount1;
			contract = new Account(RecordTypeId=rectCo1[0].Id ,Name ='contractName',ParentId = myAccount1.id,Agent_Ref__c =myAccount1.id, Contract_Department_Class__c = 'ET',Contract_Decide_Start_Date__c=Date.today().addDays(-2),
            	Contract_Decide_End_Date__c = Date.today().addDays(2),Dealer_discount__c = 0.8);
       		insert contract;

			Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.id);
			insert core;
			MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof1.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com',Work_Location__c = '重庆');
			insert MyUser_Test;

		}
		User MyUser_Test2 = [select Id from User where Id = '00510000000gmxH'];
		System.runAs(MyUser_Test){
		// System.runAs(MyUser_Test2){
		// System.runAs(MyUser_Test){
			//产品数据
			Product2 prod01 = new Product2(Name='Test01',
								ProductCode='Test01',
								Asset_Model_No__c = 'Test01',
								SFDA_Status__c = '有効',
								Product_Status__c = '正常销售',
								SFDA_Approbated_Status__c = '有效',
								Category3__c = 'CDS',
								Category4__c = 'OER',
								Category5__c = '其它',
								Dealer_special_Object__c = true,
								SFDA_Approbation_No__c = 'Test001',
								Packing_list_manual__c = 1,
								SFDA_Expiration_Date__c= Date.today(),
								Intra_Trade_List_RMB_1__c = 1000,
								Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
								Manual_Entry__c = false);

			Product2 prod02 = new Product2(Name='Test02',
								ProductCode='Test02',
								Asset_Model_No__c = 'Test02',
								SFDA_Status__c = '有効',
								Product_Status__c = '正常销售',
								SFDA_Approbated_Status__c = '有效',
								Category3__c = 'ENT',
								Category4__c = 'Celon',
								Category5__c = 'Celon',
								Dealer_special_Object__c = true,
								SFDA_Approbation_No__c = 'Test002',
								Packing_list_manual__c = 1,
								SFDA_Expiration_Date__c= Date.today(),
								Intra_Trade_List_RMB_1__c = 1000,
								Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
								Manual_Entry__c = false);

			Product2 prod03 = new Product2(Name='Test03',
								ProductCode='Test03',
								Asset_Model_No__c = 'Test03',
								SFDA_Status__c = '有効',
								Dealer_special_Object__c = true,
								Product_Status__c = '正常销售',
								SFDA_Approbated_Status__c = '有效',
								Category3__c = 'US',
								Category4__c = 'ALOKA',
								Category5__c = '体外超声',
								Intra_Trade_List_RMB_1__c = 1000,
								Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
								Manual_Entry__c = false);
	        insert new Product2[] {prod01,prod02,prod03};

			//制作产品
			Product2__c proG = new Product2__c(Name='MH-155:白平衡帽',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
			insert proG;
			System.debug('proG:'+proG);
			System.debug('proG1:'+proG.Estimation_Entry_Possibility__c);
			System.debug('prod07:'+prod01);
			System.debug('prod071:'+prod01.Estimation_Entry_Possibility__c);
			Product2__c proH = new Product2__c(Name='MB-677:BNC电缆',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
			insert proH;
			Product2__c proF = new Product2__c(Name='TooMAJ-643R:水囊鞘管003',OT_CODE_Text__c='Test003',Product2__c = prod03.Id);
			insert proF;

			//创建医院
			Account hospital = new Account();
			hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
			hospital.Name = 'test hospital';
			hospital.Is_Active__c = '有効';
			hospital.Attribute_Type__c = '卫生部';
			hospital.Speciality_Type__c = '综合医院';
			hospital.Grade__c = '一级';
			hospital.OCM_Category__c = 'SLTV';
			hospital.Is_Medical__c = '医疗机构';
			hospital.Town__c = '东京';
			insert hospital;

			//建一条医院特价产品
			hospitalprice__c hc = new hospitalprice__c();
			hc.hospital__c = hospital.Id;
			hc.product__c = proG.Id;
			hc.aph__c = '12332';
			hc.account__c = myAccount1.Id;
			insert hc;

			//医院
			Consumable_order__c order1 = new Consumable_order__c();
			order1.Name = 'testMing1';
			order1.Order_status__c = '草案中';
			order1.RecordTypeid = System.Label.RT_ConOrder_Order;
			order1.Dealer_Info__c = myAccount1.id;
			order1.Inventory_date__c = Date.today();
        	order1.Order_type__c = '订单';
			order1.Order_ProType__c = 'ET';
			order1.orderPattern__c = 'hospitalorder';
			insert  order1;
			Consumable_orderdetails__c Orderdet1 = new Consumable_orderdetails__c();
			Orderdet1.Name = 'OCM_01_00102';
			Orderdet1.Consumable_order__c = order1.Id;
			Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
			Orderdet1.Consumable_Product__c = proG.Id;
			Orderdet1.Consumable_count__c = 4;
			insert Orderdet1;

			Consumable_order_details2__c createDetail3 = new Consumable_order_details2__c();
			createDetail3 = new Consumable_order_details2__c();
			createDetail3.Consumable_Product__c = proG.id;
			createDetail3.Asset_Model_No__c     = 'Test02';
			createDetail3.Consumable_order_minor__c =  order1.id;
			createDetail3.Consumable_Arrived_order__c = order1.id;
			createDetail3.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
			createDetail3.Asset_Model_No__c         = proG.Asset_Model_No__c;
			createDetail3.Bar_Code__c = '123';
			createDetail3.Box_Piece__c ='盒';
			createDetail3.Arrive_date__c            = Date.today();

			Oly_TriggerHandler.bypass('ConsumableAssetHander');
			insert createDetail3;

            Test.startTest();
			LexConsumableController.ConsumableorderdetailsInfo c1 = new LexConsumableController.ConsumableorderdetailsInfo(Orderdet1);
			ContentVersion v = new ContentVersion();
			LexConsumableController.ConsumableorderdetailsInfo c2 = new LexConsumableController.ConsumableorderdetailsInfo(v);
            LexConsumableController l = new LexConsumableController();
            LexConsumableController.Results re =  LexConsumableController.init('hospitalorder', order1.Id, '');
			LexConsumableController.searchConsumableorderdetails(re.userWorkLocation, re.agencyProType, re.accountName, re.accountid, re.hospitalId, re.contractId, 'testMing', '', '', '', re.category_Goods, re.specialCampaign, JSON.serialize(re.dealerProductId), re.methodType, JSON.serialize(re.consumableorderdetailsRecordsview), re.editAble, re.proLimitAndDate);
            LexConsumableController.searchorderdetails(re.methodType, re.accountid, re.hospitalId, re.contractId, re.userWorkLocation, re.accountName, re.proLimitAndDate, re.editAble);
			LexConsumableController.searchConsumableorderdetails(re.userWorkLocation, re.agencyProType, re.accountName, re.accountid, hospital.Id, contract.Id, 'testMing', '', '', '', re.category_Goods, re.specialCampaign, JSON.serialize(re.dealerProductId), re.methodType, JSON.serialize(re.consumableorderdetailsRecordsview), re.editAble, re.proLimitAndDate);
            LexConsumableController.searchorderdetails(re.methodType, re.accountid, hospital.Id, contract.Id, re.userWorkLocation, re.accountName, re.proLimitAndDate, re.editAble);
            Test.stopTest();
        }
    }

	@IsTest
    static void ConsumableOrderappro(){
        user MyUser_Test;
        Account myAccount1;
		Account contract;
        User thisUser = [ select Id from User where Id = :UserInfo.getUserId()];
        NoteStay__c n = new NoteStay__c(Name = 'NoteStay',IsStay__c = true);
        insert n;
        System.runAs(thisUser){
			Profile prof1 = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
			List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
			List<RecordType> rectCo1 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'AgencyContract'];

			if (rectCo.size() == 0) {
				return;
			}
			StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
			myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '8888888',Product_Limit_Date__c = 'Test07|3|100,Test08|10|50');
			insert myAccount1;
			contract = new Account(RecordTypeId=rectCo1[0].Id ,Name ='contractName',ParentId = myAccount1.id,Agent_Ref__c =myAccount1.id, Contract_Department_Class__c = 'ET',Contract_Decide_Start_Date__c=Date.today().addDays(-2),
            	Contract_Decide_End_Date__c = Date.today().addDays(2),Dealer_discount__c = 0.8);
       		insert contract;

			Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.id);
			insert core;
			MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof1.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com',Work_Location__c = '重庆');
			insert MyUser_Test;

		}
		User MyUser_Test2 = [select Id from User where Id = '00510000000gmxH'];
		System.runAs(MyUser_Test){
		// System.runAs(MyUser_Test2){
		// System.runAs(MyUser_Test){
			//产品数据
			Product2 prod01 = new Product2(Name='Test01',
								ProductCode='Test01',
								Asset_Model_No__c = 'Test01',
								SFDA_Status__c = '有効',
								Product_Status__c = '正常销售',
								SFDA_Approbated_Status__c = '有效',
								Category3__c = 'CDS',
								Category4__c = 'OER',
								Category5__c = '其它',
								Dealer_special_Object__c = true,
								SFDA_Approbation_No__c = 'Test001',
								Packing_list_manual__c = 1,
								SFDA_Expiration_Date__c= Date.today(),
								Intra_Trade_List_RMB_1__c = 1000,
								Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
								Manual_Entry__c = false);

			Product2 prod02 = new Product2(Name='Test02',
								ProductCode='Test02',
								Asset_Model_No__c = 'Test02',
								SFDA_Status__c = '有効',
								Product_Status__c = '正常销售',
								SFDA_Approbated_Status__c = '有效',
								Category3__c = 'ENT',
								Category4__c = 'Celon',
								Category5__c = 'Celon',
								Dealer_special_Object__c = true,
								SFDA_Approbation_No__c = 'Test002',
								Packing_list_manual__c = 1,
								SFDA_Expiration_Date__c= Date.today(),
								Intra_Trade_List_RMB_1__c = 1000,
								Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
								Manual_Entry__c = false);

			Product2 prod03 = new Product2(Name='Test03',
								ProductCode='Test03',
								Asset_Model_No__c = 'Test03',
								SFDA_Status__c = '有効',
								Dealer_special_Object__c = true,
								Product_Status__c = '正常销售',
								SFDA_Approbated_Status__c = '有效',
								Category3__c = 'US',
								Category4__c = 'ALOKA',
								Category5__c = '体外超声',
								Intra_Trade_List_RMB_1__c = 1000,
								Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
								Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
								Manual_Entry__c = false);
	        insert new Product2[] {prod01,prod02,prod03};

			//制作产品
			Product2__c proG = new Product2__c(Name='MH-155:白平衡帽',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
			insert proG;
			System.debug('proG:'+proG);
			System.debug('proG1:'+proG.Estimation_Entry_Possibility__c);
			System.debug('prod07:'+prod01);
			System.debug('prod071:'+prod01.Estimation_Entry_Possibility__c);
			Product2__c proH = new Product2__c(Name='MB-677:BNC电缆',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
			insert proH;
			Product2__c proF = new Product2__c(Name='TooMAJ-643R:水囊鞘管003',OT_CODE_Text__c='Test003',Product2__c = prod03.Id);
			insert proF;

			//创建医院
			Account hospital = new Account();
			hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
			hospital.Name = 'test hospital';
			hospital.Is_Active__c = '有効';
			hospital.Attribute_Type__c = '卫生部';
			hospital.Speciality_Type__c = '综合医院';
			hospital.Grade__c = '一级';
			hospital.OCM_Category__c = 'SLTV';
			hospital.Is_Medical__c = '医疗机构';
			hospital.Town__c = '东京';
			insert hospital;

			//建一条医院特价产品
			hospitalprice__c hc = new hospitalprice__c();
			hc.hospital__c = hospital.Id;
			hc.product__c = proG.Id;
			hc.aph__c = '12332';
			hc.account__c = myAccount1.Id;
			insert hc;

			//医院
			Consumable_order__c order1 = new Consumable_order__c();
			order1.Name = 'testMing1';
			order1.Order_status__c = '已提交';
			order1.RecordTypeid = System.Label.RT_ConOrder_Order;
			order1.Dealer_Info__c = myAccount1.id;
			order1.Inventory_date__c = Date.today();
        	order1.Order_type__c = '订单';
			order1.Order_ProType__c = 'ET';
			order1.orderPattern__c = 'hospitalorder';
			insert  order1;
			Consumable_orderdetails__c Orderdet1 = new Consumable_orderdetails__c();
			Orderdet1.Name = 'OCM_01_00102';
			Orderdet1.Consumable_order__c = order1.Id;
			Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
			Orderdet1.Consumable_Product__c = proG.Id;
			Orderdet1.Consumable_count__c = 4;
			insert Orderdet1;

			Consumable_order_details2__c createDetail3 = new Consumable_order_details2__c();
			createDetail3 = new Consumable_order_details2__c();
			createDetail3.Consumable_Product__c = proG.id;
			createDetail3.Asset_Model_No__c     = 'Test02';
			createDetail3.Consumable_order_minor__c =  order1.id;
			createDetail3.Consumable_Arrived_order__c = order1.id;
			createDetail3.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
			createDetail3.Asset_Model_No__c         = proG.Asset_Model_No__c;
			createDetail3.Bar_Code__c = '123';
			createDetail3.Box_Piece__c ='盒';
			createDetail3.Arrive_date__c            = Date.today();

			Oly_TriggerHandler.bypass('ConsumableAssetHander');
			insert createDetail3;

            Test.startTest();
			LexConsumableController.ConsumableorderdetailsInfo c1 = new LexConsumableController.ConsumableorderdetailsInfo(Orderdet1);
			ContentVersion v = new ContentVersion();
			LexConsumableController.ConsumableorderdetailsInfo c2 = new LexConsumableController.ConsumableorderdetailsInfo(v);
            LexConsumableController l = new LexConsumableController();
            LexConsumableController.Results re =  LexConsumableController.init('promotionorder', order1.Id, '');
			LexConsumableController.searchConsumableorderdetails(re.userWorkLocation, re.agencyProType, re.accountName, re.accountid, re.hospitalId, re.contractId, 'testMing', '', '', '', re.category_Goods, re.specialCampaign, JSON.serialize(re.dealerProductId), re.methodType, JSON.serialize(re.consumableorderdetailsRecordsview), re.editAble, re.proLimitAndDate);
            LexConsumableController.searchorderdetails(re.methodType, re.accountid, re.hospitalId, re.contractId, re.userWorkLocation, re.accountName, re.proLimitAndDate, re.editAble);
			LexConsumableController.searchConsumableorderdetails(re.userWorkLocation, re.agencyProType, re.accountName, re.accountid, hospital.Id, contract.Id, 'testMing', '', '', '', re.category_Goods, re.specialCampaign, JSON.serialize(re.dealerProductId), re.methodType, JSON.serialize(re.consumableorderdetailsRecordsview), re.editAble, re.proLimitAndDate);
            LexConsumableController.searchorderdetails(re.methodType, re.accountid, hospital.Id, contract.Id, re.userWorkLocation, re.accountName, re.proLimitAndDate, re.editAble);
            Test.stopTest();
        }
    }
}