@isTest
private class OPDAutomaticSortBatchTest {
    //伪造数据
    private static void setupTestData(){
        StaticParameter.EscapeNFM001AgencyContractTrigger = true;
        StaticParameter.EscapeNFM001Trigger = true;
        Oly_TriggerHandler.bypass(ContactTriggerHandler.class.getName());
        Oly_TriggerHandler.bypass(AgencyHospitalHandler.class.getName());
        Oly_TriggerHandler.bypass(AssetHandler.class.getName());
        Boolean userProfileCheck = false;
        Date today = Date.today();
        // 获取从次月14日至再次月13日的日期
        Date startDate = today.addMonths(1).toStartOfMonth().addDays(13);
        Date endDate = today.addMonths(2).toStartOfMonth().addDays(12);
        
        opp2AuxiliarySort__c oas1 = new opp2AuxiliarySort__c();
        oas1.Name = '北京';
        oas1.type__c = 1;
        insert oas1;
        // opp2AuxiliarySort__c oas2 = new opp2AuxiliarySort__c();
        // oas2.Name = '山东';
        // oas2.type__c = 1;
        // insert oas2;
        // opp2AuxiliarySort__c oas3 = new opp2AuxiliarySort__c();
        // oas3.Name = '河北';
        // oas3.type__c = 1;
        // insert oas3;
        // opp2AuxiliarySort__c oas4 = new opp2AuxiliarySort__c();
        // oas4.Name = '上海';
        // oas4.type__c = 1;
        // insert oas4;

        // opp2AuxiliarySort__c oas5 = new opp2AuxiliarySort__c();
        // oas5.Name = '1.华北';
        // oas5.type__c = 2;
        // insert oas5;
        Opportunity opp = new Opportunity(
        Name='Opp',
        StageName='引合',
        CloseDate=Date.today().addDays(10),
        Close_Forecasted_Date__c=Date.today(),
            CurrencyIsoCode = 'CNY'
        );
        insert opp;
        Statu_Achievements__c Sac = new Statu_Achievements__c(
            name = 'zhucan_one',
            Opportunity__c = opp.id,
            DeliveryDate__c = Date.today(),
            ContractNO__c = 'ContractNO1',
            ContractAmount__c = 1000
        );
        insert Sac;
        
        RecordType rectCam =
        [SELECT Id FROM RecordType
         WHERE IsActive = true AND SobjectType = 'Campaign'
                          AND DeveloperName = 'ServiceEngineerTraining'];
        Campaign cam = new Campaign();
        cam.Name = 'cam';
        cam.Name2__c = '1234';
        cam.RecordTypeId = rectCam.Id;
        cam.StartDate = startDate.addDays(10);
        cam.EndDate = startDate.addDays(15);
        cam.Mailflg_after45__c = true;
        cam.Mailflg_cancel__c = true;
        cam.Mailflg_before15__c = true;
        cam.Mailflg_before7__c = true;
        cam.Mailflg_after3__c = true;
        insert cam;


        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();
        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.State_Master__c = al.id;
        hospital.City_Master__c = al2.id;
        hospital.Town__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;

        Contact contact2 = new Contact();
        contact2.AccountId = dep.Id;
        contact2.RecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
        contact2.FirstName = '責任者';
        contact2.LastName = 'test1经销商';
        contact2.Agency_User__c = true;
        insert contact2;
        // システム管理者
        User user = new User(Test_staff__c = true);
        user.LastName = '_サンブリッジ';
        user.FirstName = 'う';
        user.Alias = 'う';
        user.Email = 'olympusTest03@sunbridge.com';
        user.Username = 'olympusTest03@sunbridge.com';
        user.CommunityNickname = 'う';
        user.IsActive = true;
        user.EmailEncodingKey = 'ISO-2022-JP';
        user.TimeZoneSidKey = 'Asia/Tokyo';
        user.LocaleSidKey = 'ja_JP';
        user.LanguageLocaleKey = 'ja';
        user.ProfileId = System.Label.ProfileId_SystemAdmin;
        user.Job_Category__c = '销售推广';
        user.Province__c = '北京市';
        user.Dept__c='医疗华北营业本部';
        user.Use_Start_Date__c = Date.today().addMonths(-6);
        user.SalesManager__c = UserInfo.getUserId();
        user.BuchangApprovalManagerSales__c = UserInfo.getUserId();
        user.JingliApprovalManager__c = UserInfo.getUserId();
        user.BuchangApprovalManager__c = UserInfo.getUserId();
        user.ZongjianApprovalManager__c = UserInfo.getUserId();
        Test.StartTest();
        // MIXED_DML_OPERATION, DML operation on setup object is not permitted Error
        System.runAs(new User(Id = Userinfo.getUserId())) {
            Date nowday = Date.today();
            OPDPlan__c oPDPlan = new OPDPlan__c();
            oPDPlan.Status__c = '计划中';
            oPDPlan.OPDPlan_ImplementDate__c =  Date.today().addMonths(1).toStartOfMonth().addDays(14);
            oPDPlan.OPDType__c = '询价';
            oPDPlan.Related_Opportunity1_ID__c = opp.Id;
            oPDPlan.NoOpp_Reason__c = null;
            oPDPlan.OPDPlan_ImplementDate__c = startDate.addDays(3);
            oPDPlan.Campaign__c = cam.Id;
            oPDPlan.PlanProdDetail__c = '1000*1;';
            insert oPDPlan;

            OPDPlan__c oPDPlan2 = new OPDPlan__c();
            oPDPlan2.Status__c = '计划中';
            oPDPlan2.OPDPlan_ImplementDate__c =  Date.today().addMonths(1).toStartOfMonth().addDays(14);

            oPDPlan2.OPDType__c = '询价';
            oPDPlan2.Related_Opportunity1_ID__c = opp.Id;
            oPDPlan2.NoOpp_Reason__c = null;
            oPDPlan2.OPDPlan_ImplementDate__c = startDate;
            oPDPlan2.PlanProdDetail__c = '1000*1;';
            insert oPDPlan2;

            OPDPlan__c oPDPlan3 = new OPDPlan__c();
            oPDPlan3.Status__c = '计划中';
            oPDPlan3.OPDPlan_ImplementDate__c =  Date.today().addMonths(1).toStartOfMonth().addDays(14);
            oPDPlan3.OPDType__c = '询价';
            oPDPlan3.Related_Opportunity1_ID__c = opp.Id;
            oPDPlan3.NoOpp_Reason__c = null;
            oPDPlan3.OPDPlan_ImplementDate__c = startDate;
            oPDPlan3.PlanProdDetail__c = '1000*1;';

            insert oPDPlan3;
            
            Rental_Apply__c raObj = new Rental_Apply__c();
            raObj.Name = 'testra';
            raObj.OPDPlan__c = oPDPlan.Id;
            raObj.Product_category__c = 'GI';
            raObj.Demo_purpose1__c = '产品试用';
            raObj.demo_purpose2__c = FixtureUtil.raDemo_purpose2MAP.get('shiyongwuxunjia');
            raObj.direct_send__c = '医疗机构';
            raObj.Loaner_received_staff__c = '王五';
            raObj.Loaner_received_staff_phone__c = '110';
            raObj.direct_shippment_address__c = '北京市';
            raObj.Hospital__c = hospital.Id;
            raObj.Strategic_dept__c = strategicDep[0].Id;
            raObj.Account__c = dep.Id;
            raObj.Request_shipping_day__c = Date.toDay();  // 希望到货日
            raObj.Hope_Lonaer_date_Num__c = 1;  // 希望借用天数
            raObj.applyUser__c = Userinfo.getUserId();
            raObj.Person_In_Charge__c = Userinfo.getUserId();
            raObj.Phone_number__c = '1234567890';
            raObj.Loaner_medical_Staff__c = contact2.Id;
            raObj.Add_Approval_Status__c = '';
            raObj.Request_approval_time__c = Date.toDay(); 
            insert raObj;

            Rental_Apply__c raObj1 = new Rental_Apply__c();
            raObj1.Name = 'testra';
            raObj1.OPDPlan__c = oPDPlan3.Id;
            raObj1.Product_category__c = 'GI';
            raObj1.Demo_purpose1__c = '产品试用';
            raObj1.demo_purpose2__c = FixtureUtil.raDemo_purpose2MAP.get('shiyongwuxunjia');
            raObj1.direct_send__c = '医疗机构';
            raObj1.Loaner_received_staff__c = '王五';
            raObj1.Loaner_received_staff_phone__c = '110';
            raObj1.direct_shippment_address__c = '北京市';
            raObj1.Hospital__c = hospital.Id;
            raObj1.Strategic_dept__c = strategicDep[0].Id;
            raObj1.Account__c = dep.Id;
            raObj1.Request_shipping_day__c = Date.toDay();  // 希望到货日
            raObj1.Hope_Lonaer_date_Num__c = 1;  // 希望借用天数
            raObj1.applyUser__c = Userinfo.getUserId();
            raObj1.Person_In_Charge__c = Userinfo.getUserId();
            raObj1.Phone_number__c = '1234567890';
            raObj1.Loaner_medical_Staff__c = contact2.Id;
            raObj1.Add_Approval_Status__c = '';
            raObj1.Request_approval_time__c = Date.toDay(); 
            insert raObj1;

            Rental_Apply__c raObj2 = new Rental_Apply__c();
            raObj2.Name = 'testra';
            raObj2.OPDPlan__c = oPDPlan2.Id;
            raObj2.Product_category__c = 'GI';
            raObj2.Demo_purpose1__c = '产品试用';
            raObj2.demo_purpose2__c = FixtureUtil.raDemo_purpose2MAP.get('shiyongwuxunjia');
            raObj2.direct_send__c = '医疗机构';
            raObj2.Loaner_received_staff__c = '王五';
            raObj2.Loaner_received_staff_phone__c = '110';
            raObj2.direct_shippment_address__c = '北京市';
            raObj2.Hospital__c = hospital.Id;
            raObj2.Strategic_dept__c = strategicDep[0].Id;
            raObj2.Account__c = dep.Id;
            raObj2.Request_shipping_day__c = Date.toDay();  // 希望到货日
            raObj2.Hope_Lonaer_date_Num__c = 1;  // 希望借用天数
            raObj2.applyUser__c = Userinfo.getUserId();
            raObj2.Person_In_Charge__c = Userinfo.getUserId();
            raObj2.Phone_number__c = '1234567890';
            raObj2.Loaner_medical_Staff__c = contact2.Id;
            raObj2.Add_Approval_Status__c = '';
            raObj2.Request_approval_time__c = Date.toDay(); 
            insert raObj2;
        }
    }
    static testMethod void OPDAutomaticSortBatch1() {
        setupTestData();
        Database.executeBatch(new OPDAutomaticSortBatch(true),1);
        Test.stopTest();
    }
    static testMethod void OPDAutomaticSortBatch2() {
        setupTestData();
        List<String> sList = new List<String>{'北京'};
        Database.executeBatch(new OPDAutomaticSortBatch(sList),1);
        Test.stopTest();
    }
    static testMethod void OPDAutomaticSortBatch3() {
        setupTestData();
        Database.executeBatch(new OPDAutomaticSortBatch(),1);
        Test.stopTest();
    }
    private static void setupTestData1(){
        User user = new User();
        System.runAs(new User(Id = Userinfo.getUserId())) {
            String flag='NG2';
            String d1='产品试用';
            String dept='医疗华北营业本部';
            user = new User(Test_staff__c = true);
            user.LastName = '_サンブリッジ';
            user.FirstName = 'う';
            user.Alias = 'う';
            user.Email = 'olympusTest03@sunbridge.com';
            user.Username = 'olympusTest03@sunbridge.com';
            user.CommunityNickname = 'う';
            user.IsActive = true;
            user.EmailEncodingKey = 'ISO-2022-JP';
            user.TimeZoneSidKey = 'Asia/Tokyo';
            user.LocaleSidKey = 'ja_JP';
            user.LanguageLocaleKey = 'ja';
            user.ProfileId = System.Label.ProfileId_SystemAdmin;
            user.Province__c = '北京市';
            user.Dept__c = dept;
            user.Job_Category__c = '销售推广';
            user.Use_Start_Date__c = Date.today().addMonths(-6);
            insert user;
        }
        Boolean userProfileCheck = false;
        // 获取从次月14日至再次月13日的日期
        Date today = Date.today();
        // 获取从次月14日至再次月13日的日期
        Date startDate = today.addMonths(1).toStartOfMonth().addDays(13);
        Date endDate = today.addMonths(2).toStartOfMonth().addDays(12);
        // opp2AuxiliarySort__c oas1 = new opp2AuxiliarySort__c();
        // oas1.Name = '北京';
        // oas1.type__c = 12;
        // insert oas1;
        // opp2AuxiliarySort__c oas2 = new opp2AuxiliarySort__c();
        // oas2.Name = '山东';
        // oas2.type__c = 1;
        // insert oas2;
        // opp2AuxiliarySort__c oas3 = new opp2AuxiliarySort__c();
        // oas3.Name = '河北';
        // oas3.type__c = 1;
        // insert oas3;
        // opp2AuxiliarySort__c oas4 = new opp2AuxiliarySort__c();
        // oas4.Name = '上海';
        // oas4.type__c = 1;
        // insert oas4;

        opp2AuxiliarySort__c oas5 = new opp2AuxiliarySort__c();
        oas5.Name = '1.华北';
        oas5.type__c = 2;
        insert oas5;
        Opportunity opp = new Opportunity(
        Name='Opp',
        StageName='引合',
        CloseDate=Date.today().addDays(10),
        Close_Forecasted_Date__c=Date.today(),
            CurrencyIsoCode = 'CNY'
        );
        insert opp;
        Statu_Achievements__c Sac = new Statu_Achievements__c(
            name = 'zhucan_one',
            Opportunity__c = opp.id,
            DeliveryDate__c = Date.today(),
            ContractNO__c = 'ContractNO1',
            ContractAmount__c = 1000
        );
        insert Sac;
        
        RecordType rectCam =
        [SELECT Id FROM RecordType
         WHERE IsActive = true AND SobjectType = 'Campaign'
                          AND DeveloperName = 'ServiceEngineerTraining'];
        Campaign cam = new Campaign();
        cam.Name = 'cam';
        cam.Name2__c = '1234';
        cam.RecordTypeId = rectCam.Id;
        cam.StartDate = startDate.addDays(10);
        cam.EndDate = startDate.addDays(15);
        cam.Mailflg_after45__c = true;
        cam.Mailflg_cancel__c = true;
        cam.Mailflg_before15__c = true;
        cam.Mailflg_before7__c = true;
        cam.Mailflg_after3__c = true;
        insert cam;


        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();
        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.State_Master__c = al.id;
        hospital.City_Master__c = al2.id;
        hospital.Town__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;

        Contact contact2 = new Contact();
        contact2.AccountId = dep.Id;
        contact2.RecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
        contact2.FirstName = '責任者';
        contact2.LastName = 'test1经销商';
        contact2.Agency_User__c = true;
        insert contact2;
        Date nowday = Date.today();
        OPDPlan__c oPDPlan = new OPDPlan__c();
        oPDPlan.Status__c = '计划中';
        oPDPlan.OPDPlan_ImplementDate__c =  startDate;
        oPDPlan.OPDType__c = '询价';
        oPDPlan.Related_Opportunity1_ID__c = opp.Id;
        oPDPlan.NoOpp_Reason__c = null;
        oPDPlan.Campaign__c = cam.Id;
        oPDPlan.PlanProdDetail__c = '1000*1;';
        oPDPlan.OPDLendSort__c = 3;
        oPDPlan.OPDLendSortDraft__c = 3;
        oPDPlan.If_AutoSort__c = 1;
        oPDPlan.SortDate__c = Date.today();
        oPDPlan.SortOperator__c = userInfo.getUserId();
        insert oPDPlan;

        OPDPlan__c oPDPlan2 = new OPDPlan__c();
        oPDPlan2.Status__c = '计划中';
        oPDPlan2.OPDPlan_ImplementDate__c =  startDate.addDays(1);

        oPDPlan2.OPDType__c = '询价';
        oPDPlan2.Related_Opportunity1_ID__c = opp.Id;
        oPDPlan2.NoOpp_Reason__c = null;
        oPDPlan2.PlanProdDetail__c = '1000*1;';
        oPDPlan2.OPDLendSort__c = 3;
        oPDPlan2.OPDLendSortDraft__c = 3;
        oPDPlan2.If_AutoSort__c = 1;
        oPDPlan2.SortDate__c = Date.today();
        oPDPlan2.SortOperator__c = userInfo.getUserId();
        insert oPDPlan2;

        OPDPlan__c oPDPlan3 = new OPDPlan__c();
        oPDPlan3.Status__c = '计划中';
        oPDPlan3.OPDPlan_ImplementDate__c =  startDate;
        oPDPlan3.OPDType__c = '询价';
        oPDPlan3.Related_Opportunity1_ID__c = opp.Id;
        oPDPlan3.NoOpp_Reason__c = null;
        oPDPlan3.PlanProdDetail__c = '1000*1;';
        oPDPlan3.OPDLendSort__c = 3;
        oPDPlan3.OPDLendSortDraft__c = 3;
        oPDPlan3.If_AutoSort__c = 1;
        oPDPlan3.SortDate__c = Date.today();
        oPDPlan3.SortOperator__c = userInfo.getUserId();

        insert oPDPlan3;
        Test.StartTest();
        System.runAs(new User(Id = user.id)) {
            Rental_Apply__c raObj = new Rental_Apply__c();
            raObj.Name = 'testra';
            raObj.OPDPlan__c = oPDPlan.Id;
            raObj.Product_category__c = 'GI';
            raObj.Demo_purpose1__c = '产品试用';
            raObj.demo_purpose2__c = FixtureUtil.raDemo_purpose2MAP.get('shiyongwuxunjia');
            raObj.direct_send__c = '医疗机构';
            raObj.Loaner_received_staff__c = '王五';
            raObj.Loaner_received_staff_phone__c = '110';
            raObj.direct_shippment_address__c = '北京市';
            raObj.Hospital__c = hospital.Id;
            raObj.Strategic_dept__c = strategicDep[0].Id;
            raObj.Account__c = dep.Id;
            raObj.Request_shipping_day__c = startDate.addDays(-3);  // 希望到货日
            raObj.Hope_Lonaer_date_Num__c = 1;  // 希望借用天数
            raObj.applyUser__c = user.id;
            raObj.Person_In_Charge__c = user.id;
            raObj.Phone_number__c = '1234567890';
            raObj.Loaner_medical_Staff__c = contact2.Id;
            raObj.Add_Approval_Status__c = '';
            raObj.Request_approval_time__c = Date.toDay(); 
            raObj.Status__c = '草案中';
            raObj.OwnerId = user.id;
            insert raObj;

            Rental_Apply__c raObj1 = new Rental_Apply__c();
            raObj1.Name = 'testra';
            raObj1.OPDPlan__c = oPDPlan3.Id;
            raObj1.Product_category__c = 'GI';
            raObj1.Demo_purpose1__c = '产品试用';
            raObj1.demo_purpose2__c = FixtureUtil.raDemo_purpose2MAP.get('shiyongwuxunjia');
            raObj1.direct_send__c = '医疗机构';
            raObj1.Loaner_received_staff__c = '王五';
            raObj1.Loaner_received_staff_phone__c = '110';
            raObj1.direct_shippment_address__c = '北京市';
            raObj1.Hospital__c = hospital.Id;
            raObj1.Strategic_dept__c = strategicDep[0].Id;
            raObj1.Account__c = dep.Id;
            raObj1.Request_shipping_day__c = startDate.addDays(-3);  // 希望到货日
            raObj1.Hope_Lonaer_date_Num__c = 1;  // 希望借用天数
            raObj1.applyUser__c = user.id;
            raObj1.Person_In_Charge__c = user.id;
            raObj1.Phone_number__c = '1234567890';
            raObj1.Loaner_medical_Staff__c = contact2.Id;
            raObj1.Add_Approval_Status__c = '';
            raObj1.Request_approval_time__c = Date.toDay(); 
            raObj1.Status__c = '草案中';
            raObj1.OwnerId = user.id;
            insert raObj1;

            Rental_Apply__c raObj2 = new Rental_Apply__c();
            raObj2.Name = 'testra';
            raObj2.OPDPlan__c = oPDPlan2.Id;
            raObj2.Product_category__c = 'GI';
            raObj2.Demo_purpose1__c = '产品试用';
            raObj2.demo_purpose2__c = FixtureUtil.raDemo_purpose2MAP.get('shiyongwuxunjia');
            raObj2.direct_send__c = '医疗机构';
            raObj2.Loaner_received_staff__c = '王五';
            raObj2.Loaner_received_staff_phone__c = '110';
            raObj2.direct_shippment_address__c = '北京市';
            raObj2.Hospital__c = hospital.Id;
            raObj2.Strategic_dept__c = strategicDep[0].Id;
            raObj2.Account__c = dep.Id;
            raObj2.Request_shipping_day__c = startDate.addDays(-3);  // 希望到货日
            raObj2.Hope_Lonaer_date_Num__c = 1;  // 希望借用天数
            raObj2.applyUser__c = user.id;
            raObj2.Person_In_Charge__c = user.id;
            raObj2.Phone_number__c = '1234567890';
            raObj2.Loaner_medical_Staff__c = contact2.Id;
            raObj2.Add_Approval_Status__c = '';
            raObj2.Request_approval_time__c = Date.toDay(); 
            raObj2.Status__c = '草案中';
            raObj2.OwnerId = user.id;
            insert raObj2;
        }
    }
    static testMethod void RentalAutomaticSortBatch() {
        setupTestData1();
        Database.executeBatch(new RentalAutomaticSortBatch(true,false),1);
        Test.stopTest();
    }
    static testMethod void RentalAutomaticSortBatch1() {
        setupTestData1();
        List<String> sList = new List<String>{'1.华北'};
        Database.executeBatch(new RentalAutomaticSortBatch(sList),1);
        Test.stopTest();
    } 
    static testMethod void RentalAutomaticSortBatch2() {
        setupTestData1();
        Database.executeBatch(new RentalAutomaticSortBatch(),1);
        Test.stopTest();
    }           
}