binxie
2023-06-26 de9565270a88b0749d17c1961cd41399c8483c96
force-app/main/default/classes/updateESignBatchTest.cls
@@ -2,33 +2,46 @@
private class updateESignBatchTest {
    //测试经销商收货
    static testMethod void testMethod1() {
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -39,7 +52,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -72,13 +85,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -107,7 +124,6 @@
       eSignForm.Statu_Achievements__c = Sac.Id;
       eSignForm.Name = '::测试电子签收单';
       insert eSignForm;
        eSignFormEntry__c eSignFormEntry1 = new eSignFormEntry__c();
@@ -130,7 +146,6 @@
        eSignFormEntry2.HPConfirmDateBack__c = Date.today().addDays(-2);
       // eSignFormEntry2.createdDate = Date.today().addDays(-2);
       insert eSignFormEntry2;
        //新建电子签收单明细
        eSignFormLineItem__c eSignFormLineItem = new eSignFormLineItem__c();
@@ -155,7 +170,7 @@
        insert eSignFormLineItemEntry2;
        list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -179,40 +194,52 @@
        Test.startTest();
        Database.executeBatch(new updateESignBatch(), 20);
        Test.stopTest();
    }
    //测试经销商确认
    static testMethod void testMethod2() {
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -223,7 +250,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -256,13 +283,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -313,7 +344,6 @@
        // eSignFormEntry2.createdDate = Date.today().addDays(-2);
        insert eSignFormEntry2;
        //新建电子签收单明细
        eSignFormLineItem__c eSignFormLineItem = new eSignFormLineItem__c();
        eSignFormLineItem.Name = '::电子签收单明细';
@@ -337,7 +367,7 @@
        insert eSignFormLineItemEntry2;
        list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -367,33 +397,46 @@
    //测试医院收货
    static testMethod void testMethod3() {
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -404,7 +447,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -437,13 +480,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -495,7 +542,6 @@
        // eSignFormEntry2.createdDate = Date.today().addDays(-2);
        insert eSignFormEntry2;
        //新建电子签收单明细
        eSignFormLineItem__c eSignFormLineItem = new eSignFormLineItem__c();
        eSignFormLineItem.Name = '::电子签收单明细';
@@ -519,7 +565,7 @@
        insert eSignFormLineItemEntry2;
        list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -546,33 +592,46 @@
    //测试医院确认
    static testMethod void testMethod4() {
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -583,7 +642,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -616,13 +675,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -674,7 +737,6 @@
        // eSignFormEntry2.createdDate = Date.today().addDays(-2);
        insert eSignFormEntry2;
        //新建电子签收单明细
        eSignFormLineItem__c eSignFormLineItem = new eSignFormLineItem__c();
        eSignFormLineItem.Name = '::电子签收单明细';
@@ -698,7 +760,7 @@
        insert eSignFormLineItemEntry2;
        list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -724,35 +786,47 @@
        Test.stopTest();
    }
    static testMethod void testMethod5() {
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -763,7 +837,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -796,13 +870,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -924,7 +1002,7 @@
        insert eSignFormLineItemEntry2;
       list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -952,33 +1030,46 @@
    }
    static testMethod void testMethod6() {
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -989,7 +1080,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -1022,13 +1113,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -1150,7 +1245,7 @@
        insert eSignFormLineItemEntry2;
       list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -1177,33 +1272,46 @@
    }
    static testMethod void testMethod7() {
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -1214,7 +1322,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -1247,13 +1355,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -1375,7 +1487,7 @@
        insert eSignFormLineItemEntry2;
        list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -1404,33 +1516,46 @@
    }
    static testMethod void testMethod8() {
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -1441,7 +1566,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -1474,13 +1599,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -1602,7 +1731,7 @@
        insert eSignFormLineItemEntry2;
       list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -1630,33 +1759,46 @@
    }
    static testMethod void testMethod9() {
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -1667,7 +1809,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -1700,13 +1842,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -1828,7 +1974,7 @@
        insert eSignFormLineItemEntry2;
        list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -1857,33 +2003,46 @@
    }
    static testMethod void testMethod10() {
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -1894,7 +2053,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -1927,13 +2086,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -2055,7 +2218,7 @@
        insert eSignFormLineItemEntry2;
       list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -2086,33 +2249,46 @@
    //测试经销商收货
    static testMethod void testMethod11() {
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -2123,7 +2299,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -2156,13 +2332,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -2229,7 +2409,6 @@
        // eSignFormEntry2.createdDate = Date.today().addDays(-2);
        insert eSignFormEntry4;
        //新建电子签收单明细
        eSignFormLineItem__c eSignFormLineItem = new eSignFormLineItem__c();
        eSignFormLineItem.Name = '::电子签收单明细';
@@ -2267,7 +2446,7 @@
        insert eSignFormLineItemEntry4;
        list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -2294,33 +2473,46 @@
    }
    //测试医院确认
    static testMethod void testMethod12() {
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -2331,7 +2523,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -2364,13 +2556,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -2422,7 +2618,6 @@
        // eSignFormEntry2.createdDate = Date.today().addDays(-2);
        insert eSignFormEntry2;
        //新建电子签收单明细
        eSignFormLineItem__c eSignFormLineItem = new eSignFormLineItem__c();
        eSignFormLineItem.Name = '::电子签收单明细';
@@ -2446,7 +2641,7 @@
        insert eSignFormLineItemEntry2;
        list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -2474,33 +2669,46 @@
        //测试经销商收货
    static testMethod void testMethod13() {
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -2511,7 +2719,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -2544,13 +2752,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -2584,8 +2796,6 @@
        eSignForm.agencyRejectDate__c   = Date.today().addDays(2);
        eSignForm.HPRejectDate__c   = Date.today().addDays(2);
        insert eSignForm;
/*        eSignFormEntry__c eSignFormEntry1 = new eSignFormEntry__c();
@@ -2609,12 +2819,10 @@
        // eSignFormEntry2.createdDate = Date.today().addDays(-2);
        insert eSignFormEntry2;*/
        //新建电子签收单明细
        eSignFormLineItem__c eSignFormLineItem = new eSignFormLineItem__c();
        eSignFormLineItem.Name = '::电子签收单明细';
        eSignFormLineItem.eSignForm__c = eSignForm.Id;
        insert eSignFormLineItem;
@@ -2634,7 +2842,7 @@
        insert eSignFormLineItemEntry2;*/
        list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -2658,42 +2866,52 @@
        Test.startTest();
        Database.executeBatch(new updateESignBatch(), 20);
        Test.stopTest();
    }
     //跑单独方法
    @isTest
    private static void test_upsertESignLineItems() {
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -2704,7 +2922,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -2737,13 +2955,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -2767,16 +2989,12 @@
        );
        insert Sac;
        //新建电子签收单
        eSignForm__c eSignForm = new eSignForm__c();
        eSignForm.Statu_Achievements__c = Sac.Id;
        eSignForm.Name = '::测试电子签收单';
        
        insert eSignForm;
        //新建电子签收单明细
        eSignFormLineItem__c eSignFormLineItem = new eSignFormLineItem__c();
@@ -2784,8 +3002,6 @@
        eSignFormLineItem.eSignForm__c = eSignForm.Id;
        insert eSignFormLineItem;
        /*list<Attachment> attachmentList = new list<Attachment>();
        Attachment attach=new Attachment();     
@@ -2893,7 +3109,6 @@
        // }
        OCM_Management_Province__c mp1 = new OCM_Management_Province__c();
        mp1.Name = '江西';
        mp1.GI_assistant__c = UserInfo.getUserId();
@@ -2914,38 +3129,50 @@
        eSignFormList.add(eSignForm);
        updateESignBatch.updateOwner(provinceList,provinceMap,eSignFormList,true);
    }
        //测试经销商收货
    static testMethod void testMethod14() {
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        List<RecordType> rectSct = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '戦略科室分類 呼吸科'
        ];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
        List<RecordType> rectDpt = [
            SELECT Id, Name
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name IN ('診療科 消化科', '診療科 呼吸科')
            ORDER BY Name DESC
        ];
        if (rectDpt.size() == 0) {
            return;
        }
         List<RecordType> rectAs = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '备品'];
        List<RecordType> rectAs = [SELECT Id, Name FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Asset' AND Name = '备品'];
        if (rectAs.size() == 0) {
            return;
        }
     
        // insert hospital
        Account company1 = new Account();
        company1.RecordTypeId = rectCo[0].Id;
        company1.Name = '病院テスト1';
        company1.OCM_man_province_txt__c = '江西';
        List<Account> hps = new Account[]{company1};
        List<Account> hps = new List<Account>{ company1 };
        insert hps;
          
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
        List<Account> dc1s = [
            SELECT Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c
            FROM Account
            WHERE Parent.Id = :company1.Id
            ORDER BY Department_Class_Label__c
        ];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
@@ -2956,7 +3183,7 @@
        depart1.Hospital__c         = company1.Id;
        depart1.OCM_man_province_txt__c = '江西';
        
        insert new Account[] {depart1};
        insert new List<Account>{ depart1 };
        List<Product2> prdList = new List<Product2>();
        Product2 prd1 = new Product2();
@@ -2989,13 +3216,17 @@
        insert ast;
        
        Asset ast1 = [select RecordTypeID__c from Asset where Id =: ast.Id];
        Asset ast1 = [SELECT RecordTypeID__c FROM Asset WHERE Id = :ast.Id];
        
        String RecordTypeID = ast1.RecordTypeID__c;
           
        System.assertEquals(RecordTypeID , ast.RecordTypeId);
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        RecordType rectOpp = [
            SELECT id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Opportunity' AND DeveloperName = 'Opportunity'
        ];
        Opportunity opp = new Opportunity(
               Name='testOpp1',
               StageName='引合',
@@ -3026,14 +3257,12 @@
        eSignForm.agencyRejectDate__c   = Date.today().addDays(2);
        eSignForm.HPRejectDate__c   = Date.today().addDays(2);
        insert eSignForm;
        eSignFormEntry__c eSignFormEntry1 = new eSignFormEntry__c();
        eSignFormEntry1.Name = '::电子签收单录入表1';
        eSignFormEntry1.eSignForm__c = eSignForm.Id;
        eSignFormEntry1.entryType__c = '经销商收货';
        
        insert eSignFormEntry1;
@@ -3050,7 +3279,6 @@
        eSignFormEntry2.HPConfirmDateBack__c = Date.today().addDays(-2);
        // eSignFormEntry2.createdDate = Date.today().addDays(-2);
        insert eSignFormEntry2;
        //新建电子签收单明细
        eSignFormLineItem__c eSignFormLineItem = new eSignFormLineItem__c();
@@ -3075,7 +3303,7 @@
        insert eSignFormLineItemEntry2;
        list<Attachment> attachmentList = new list<Attachment>();
        list<Attachment> attachmentList = new List<Attachment>();
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
@@ -3093,7 +3321,6 @@
        attach1.parentId=eSignForm.id;
        attach1.ContentType = 'application/pdf';
        
        attachmentList.add(attach1);
        Attachment attach2=new Attachment();     
@@ -3103,21 +3330,13 @@
        attach2.parentId=eSignForm.id;
        attach2.ContentType = 'application/pdf';
        
        attachmentList.add(attach2);
        insert attachmentList;
        Test.startTest();
        Database.executeBatch(new updateESignBatch(), 20);
        Test.stopTest();
    }
    static testMethod void testMethod15(){
        Test.startTest();
        updateESignBatch.improveTestRate();
        Test.stopTest();
    }
}