buli
2023-07-14 e6068da47c1bef5517c9e5fdc8c726766867ad4e
force-app/main/default/classes/LexSummonsCreatControllerTest.cls
@@ -1,28 +1,49 @@
@isTest
private class LexSummonsCreatControllerTest {
    @isTest
    static void testInit(){
    static void testInit() {
        Account accountItem1;
        Account accountItem2;
        User userTest;
        String rectCo = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
        String rectHp = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
        Profile prof = [SELECT Id FROM Profile WHERE Name ='901_经销商社区普通权限_2重验证(ET)'];
        accountItem1 = new Account(Name='Testaccount001',RecordTypeId = rectCo, AgentCode_Ext__c = '9999900');
        Profile prof = [SELECT Id FROM Profile WHERE Name = '901_经销商社区普通权限_2重验证(ET)'];
        accountItem1 = new Account(Name = 'Testaccount001', RecordTypeId = rectCo, AgentCode_Ext__c = '9999900');
        insert accountItem1;
        accountItem2 = new Account(Name='Testaccount002',RecordTypeId = rectHp, AgentCode_Ext__c = '9999999', ParentId = accountItem1.Id,Contract_Decide_Start_Date__c = Date.today(),ENG_Dealer__c = true,BillingCity = null);
        accountItem2 = new Account(
            Name = 'Testaccount002',
            RecordTypeId = rectHp,
            AgentCode_Ext__c = '9999999',
            ParentId = accountItem1.Id,
            Contract_Decide_Start_Date__c = Date.today(),
            ENG_Dealer__c = true,
            BillingCity = null
        );
        insert accountItem2;
        Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe', lastname='Plumber', accountId = accountItem1.Id);
        Contact core = new Contact(email = 'jplumber@salesforce.com', firstname = 'Joe', lastname = 'Plumber', accountId = accountItem1.Id);
        insert core;
        Agency_Hospital_Link__c ahl = new Agency_Hospital_Link__c();
        ahl.Name = 'test1经销商医院';
        ahl.Hospital__c = accountItem2.Id;
        ahl.Agency__c = accountItem1.Id;
        insert new Agency_Hospital_Link__c[]{ahl};
        insert new List<Agency_Hospital_Link__c>{ ahl };
        System.runAs(new user(ID = UserInfo.getUserID())) {
            userTest = New User(ContactId = core.id, Alias = 'newUser', Email='newuser@testorg.com', EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN', LocaleSidKey='zh_CN', ProfileId = prof.Id, TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com', UserPro_Type__c='ENG', Work_Location__c='北京');
            userTest = new User(
                ContactId = core.id,
                Alias = 'newUser',
                Email = 'newuser@testorg.com',
                EmailEncodingKey = 'UTF-8',
                LastName = 'TestUser',
                LanguageLocaleKey = 'zh_CN',
                LocaleSidKey = 'zh_CN',
                ProfileId = prof.Id,
                TimeZoneSidKey = 'Asia/Shanghai',
                UserName = 'testUser@testorg.com',
                UserPro_Type__c = 'ENG',
                Work_Location__c = '北京'
            );
            insert userTest;
        }
        //发货
@@ -38,30 +59,59 @@
        insert consOrder;
        // create ContentVersions
        list<ContentVersion> cvList = new list<ContentVersion>();
        cvList.add( new ContentVersion(Title = 'test1',PathOnClient ='/' + 'Test1.txt' ,VersionData = Blob.valueOf('test data 1'), IsMajorVersion = true) );
        cvList.add( new ContentVersion(Title = 'test2',PathOnClient ='/' + 'Test2.txt' ,VersionData = Blob.valueOf('test data 2'), IsMajorVersion = true) );
        cvList.add( new ContentVersion(Title = 'test3',PathOnClient ='/' + 'Test3.txt' ,VersionData = Blob.valueOf('test data 3'), IsMajorVersion = true) );
        list<ContentVersion> cvList = new List<ContentVersion>();
        cvList.add(
            new ContentVersion(
                Title = 'test1',
                PathOnClient = '/' + 'Test1.txt',
                VersionData = Blob.valueOf('test data 1'),
                IsMajorVersion = true
            )
        );
        cvList.add(
            new ContentVersion(
                Title = 'test2',
                PathOnClient = '/' + 'Test2.txt',
                VersionData = Blob.valueOf('test data 2'),
                IsMajorVersion = true
            )
        );
        cvList.add(
            new ContentVersion(
                Title = 'test3',
                PathOnClient = '/' + 'Test3.txt',
                VersionData = Blob.valueOf('test data 3'),
                IsMajorVersion = true
            )
        );
        insert cvList;
        // retrieve Ids for ContentDocuments created on insert of ContentVersions
        list<Id> cdIdList = new list<Id>();
        for (ContentDocument cd : [SELECT Id, LatestPublishedVersionId
                                    FROM ContentDocument
                                WHERE (LatestPublishedVersionId =:cvList[0].Id OR LatestPublishedVersionId =:cvList[1].Id OR LatestPublishedVersionId =:cvList[2].Id)
                                ORDER BY Title])
        {
        list<Id> cdIdList = new List<Id>();
        for (ContentDocument cd : [
            SELECT Id, LatestPublishedVersionId
            FROM ContentDocument
            WHERE
                LatestPublishedVersionId = :cvList[0].Id
                OR LatestPublishedVersionId = :cvList[1].Id
                OR LatestPublishedVersionId = :cvList[2].Id
            ORDER BY Title
        ]) {
            cdIdList.add(cd.Id);
        }
        system.assertEquals(3, cdIdList.size());
        list<ContentDocumentLink> cdlList = new list<ContentDocumentLink>();
        cdlList.add(new ContentDocumentLink(ContentDocumentId=cdIdList[0], LinkedEntityId=consOrder.Id, ShareType='V'));
        list<ContentDocumentLink> cdlList = new List<ContentDocumentLink>();
        cdlList.add(new ContentDocumentLink(ContentDocumentId = cdIdList[0], LinkedEntityId = consOrder.Id, ShareType = 'V'));
        insert cdlList;
        LexSummonsCreatController.saveFile(consOrder.Id,'A-65224941-20200923--1.docx','Unit Test Attachment Body');
        LexSummonsCreatController.getFiles(consOrder.Id);
        LexSummonsCreatController.deleteAtt(cvList[0].Id);
        System.runAs(userTest){
        LexSummonsCreatController.saveFile(consOrder.Id, 'A-65224941-20200923--1.docx', 'Unit Test Attachment Body');
        LexSummonsCreatController.getFiles(consOrder.Id);
        LexSummonsCreatController.deleteAtt(cvList[0].Id);
        System.runAs(userTest) {
            String userId = UserInfo.getUserId();
            User thisUserInfo = [SELECT accountid, UserPro_Type__c, ContactId, Contact.AccountId,Contact.Account.Name, Work_Location__c FROM User WHERE id =:userId];
            User thisUserInfo = [
                SELECT accountid, UserPro_Type__c, ContactId, Contact.AccountId, Contact.Account.Name, Work_Location__c
                FROM User
                WHERE id = :userId
            ];
            String accountId = thisUserInfo.accountid;
            String accountName = thisUserInfo.Contact.Account.Name;
            String agencyProType = thisUserInfo.UserPro_Type__c;
@@ -71,12 +121,32 @@
            if (String.isBlank(thisUserInfo.UserPro_Type__c)) {
                agencyProType = 'ET';
            }
           Product2 prod07 = new Product2(Name='Test07',ProductCode='Test07',Asset_Model_No__c = 'Test07',Category3__c = 'CDS',Category4__c = 'OER',Category5__c = 'Celon',
            SFDA_Status__c = '有効',Product_Status__c = '正常销售',SFDA_Approbated_Status__c = '有效',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test002',Packing_list_manual__c = 1,
            SFDA_Expiration_Date__c= Date.today(),Manual_Entry__c = false);
           insert new Product2[] {prod07};
            Product2__c pro1 = new Product2__c(Name='MH-155:白平衡帽',OT_CODE_Text__c='Test001',Product2__c = prod07.Id,Category3_text__c = 'test123', Category4_text__c = 'test123', Category5_text__c = 'test123');
         insert new Product2__c[] {pro1};
            Product2 prod07 = new Product2(
                Name = 'Test07',
                ProductCode = 'Test07',
                Asset_Model_No__c = 'Test07',
                Category3__c = 'CDS',
                Category4__c = 'OER',
                Category5__c = 'Celon',
                SFDA_Status__c = '有効',
                Product_Status__c = '正常销售',
                SFDA_Approbated_Status__c = '有效',
                Dealer_special_Object__c = true,
                SFDA_Approbation_No__c = 'Test002',
                Packing_list_manual__c = 1,
                SFDA_Expiration_Date__c = Date.today(),
                Manual_Entry__c = false
            );
            insert new List<Product2>{ prod07 };
            Product2__c pro1 = new Product2__c(
                Name = 'MH-155:白平衡帽',
                OT_CODE_Text__c = 'Test001',
                Product2__c = prod07.Id,
                Category3_text__c = 'test123',
                Category4_text__c = 'test123',
                Category5_text__c = 'test123'
            );
            insert new List<Product2__c>{ pro1 };
            //发货
            Consumable_order__c createIdSend = new Consumable_order__c();
            createIdSend.Name = 'testMing1';
@@ -134,7 +204,7 @@
            createIdSend3.SummonsStatus_c__c = '批准';
            createIdSend3.Dealer_Info__c = accountItem1.Id;
            createIdSend3.Delivery_detail_count__c = 5;
            Consumable_order__c createIdSend4 = new Consumable_order__c();
            createIdSend4.Name = 'testMing1';
            createIdSend4.Order_status__c = '批准';
@@ -176,7 +246,7 @@
            createIdSend6.SummonsStatus_c__c = '';
            createIdSend6.Dealer_Info__c = accountItem1.Id;
            createIdSend6.Delivery_detail_count__c = 5;
            Consumable_order__c createIdSend7 = new Consumable_order__c();
            createIdSend7.Name = 'testMing222222';
            createIdSend7.Order_status__c = '批准';
@@ -190,7 +260,7 @@
            createIdSend7.SummonsStatus_c__c = '';
            createIdSend7.Dealer_Info__c = accountItem1.Id;
            createIdSend7.Delivery_detail_count__c = 5;
            Consumable_order__c createIdSend8 = new Consumable_order__c();
            createIdSend8.Name = 'testMing222222';
            createIdSend8.Order_status__c = '批准';
@@ -205,10 +275,10 @@
            createIdSend8.Dealer_Info__c = accountItem1.Id;
            createIdSend8.Delivery_detail_count__c = 5;
           //发票信息
            //发票信息
            Consumable_order__c createIdSend9 = new Consumable_order__c();
            createIdSend9.Name = 'invoice01';
            createIdSend9.Invoice_status__c='已完成';
            createIdSend9.Invoice_status__c = '已完成';
            createIdSend9.Order_type__c = '发票';
            createIdSend9.RecordTypeid = System.Label.RT_ConOrder_Invoice;
            createIdSend9.Order_status__c = '草案中';
@@ -235,14 +305,14 @@
            createIdSend11.Order_ProType__c = 'ET';
            Consumable_order__c testList1 = new Consumable_order__c();
            testList1.Name='Test1';
            testList1.Summons_Sale_Status__c='出货';
            testList1.SummonsStatus_c__c='已完成';
            testList1.Name = 'Test1';
            testList1.Summons_Sale_Status__c = '出货';
            testList1.SummonsStatus_c__c = '已完成';
            testList1.Arrive_Order__c = createIdSend9.Id;
            testList1.SummonsForDirction__c='直接销售给医院';
            testList1.Order_status__c='草案中';
            testList1.Order_type__c='传票';
            testList1.Dealer_info__c=accountItem1.Id;
            testList1.SummonsForDirction__c = '直接销售给医院';
            testList1.Order_status__c = '草案中';
            testList1.Order_type__c = '传票';
            testList1.Dealer_info__c = accountItem1.Id;
            testList1.ConInvoice_Code__c = createIdSend9.id;
            //到货
@@ -256,12 +326,31 @@
            createIdArrived.orderPattern__c = 'promotionorder';
            createIdArrived.Dealer_Info__c = accountItem1.Id;
            createIdArrived.Delivery_detail_count__c = 5;
            insert new Consumable_order__c[]{createIdSend,createIdSend1,createIdSend2,createIdSend3,createIdSend4,createIdSend5,createIdSend6,createIdSend7,createIdSend8,createIdSend9,createIdSend10,createIdSend11,createIdArrived,testList1};
            insert new List<Consumable_order__c>{
                createIdSend,
                createIdSend1,
                createIdSend2,
                createIdSend3,
                createIdSend4,
                createIdSend5,
                createIdSend6,
                createIdSend7,
                createIdSend8,
                createIdSend9,
                createIdSend10,
                createIdSend11,
                createIdArrived,
                testList1
            };
            System.debug('createIdSend9.id = ' + createIdSend9.id);
            Consumable_order_LinkTable__c order_LinkTable1 = new Consumable_order_LinkTable__c(Name='order_LinkTable1',Outboundorder_Code_link__c = testList1.Id,Invoice_Code_link__c =createIdSend9.Id);
            insert new Consumable_order_LinkTable__c[]{order_LinkTable1};
            Consumable_order_LinkTable__c order_LinkTable1 = new Consumable_order_LinkTable__c(
                Name = 'order_LinkTable1',
                Outboundorder_Code_link__c = testList1.Id,
                Invoice_Code_link__c = createIdSend9.Id
            );
            insert new List<Consumable_order_LinkTable__c>{ order_LinkTable1 };
            Consumable_orderdetails__c coc = new Consumable_orderdetails__c();
            coc.Name = 'Too001';
@@ -301,7 +390,7 @@
            coc2.Delivery_List_RMB__c = -999.00;
            coc2.Shipment_Count__c = 9999.00;
            coc2.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
            insert new Consumable_orderdetails__c[]{coc,coc1,coc2};
            insert new List<Consumable_orderdetails__c>{ coc, coc1, coc2 };
            Consumable_order_details2__c conOrderDetail1 = new Consumable_order_details2__c();
            conOrderDetail1.Name = 'OCM_01_001001';
@@ -319,17 +408,23 @@
            conOrderDetail1.Cancellation_Flag__c = false;
            conOrderDetail1.Box_Piece__c = '盒';
            conOrderDetail1.Sterilization_limit__c = Date.Today();
            insert new Consumable_order_details2__c[]{conOrderDetail1};
            insert new List<Consumable_order_details2__c>{ conOrderDetail1 };
            hospitalprice__c hp1 = new hospitalprice__c();
            hp1.hospital__c = accountId;
            hp1.account__c = accountId;
            hp1.product__c = pro1.Id;
            insert new hospitalprice__c[]{hp1};
            insert new List<hospitalprice__c>{ hp1 };
            Dealer_elationship__c dealerelationship = new Dealer_elationship__c(Dealer_principal__c = accountItem1.id,Dealer_subordinate__c = accountItem1.id);
            Dealer_elationship__c dealerelationship1 = new Dealer_elationship__c(Dealer_principal__c = accountItem1.id,Dealer_subordinate__c = accountItem1.id);
            insert new Dealer_elationship__c[] {dealerelationship, dealerelationship1};
            Dealer_elationship__c dealerelationship = new Dealer_elationship__c(
                Dealer_principal__c = accountItem1.id,
                Dealer_subordinate__c = accountItem1.id
            );
            Dealer_elationship__c dealerelationship1 = new Dealer_elationship__c(
                Dealer_principal__c = accountItem1.id,
                Dealer_subordinate__c = accountItem1.id
            );
            insert new List<Dealer_elationship__c>{ dealerelationship, dealerelationship1 };
            LexSummonsCreatController.ConsumableorderdetailsInfo c0 = new LexSummonsCreatController.ConsumableorderdetailsInfo();
            c0.packinglist = 0;
@@ -357,7 +452,9 @@
            Map<String, String> boxorpieceMap = new Map<String, String>();
            boxorpieceMap.put('盒', '盒');
            boxorpieceMap.put('个', '个');
            LexSummonsCreatController.ConsumableorderdetailsInfo coder = new LexSummonsCreatController.ConsumableorderdetailsInfo(conOrderDetail1);
            LexSummonsCreatController.ConsumableorderdetailsInfo coder = new LexSummonsCreatController.ConsumableorderdetailsInfo(
                conOrderDetail1
            );
            coder.check = true;
            coder.oldCheck = true;
            coder.hospitalSpecialOffer = true;
@@ -387,7 +484,7 @@
            c3.Boxnumber = 10;
            c1.compareTo(c3);
            c1.Boxnumber = 20;
            c3.Boxnumber = 10;
            c3.Boxnumber = 10;
            c1.compareTo(c3);
            c3.Boxnumber = 10;
            c1.Boxnumber = 20;
@@ -493,7 +590,7 @@
            codi.boxorpiecein = null;
            codi.orderdetails1 = coc;
            codi.Prod = pro1;
            consumable.add(codi);
            consumable.add(codi);
            List<SelectOption> categoryOptionList = new List<SelectOption>();
            System.Test.startTest();
            Integer size = Integer.valueOf(System.Label.orderdetLimitsize);
@@ -502,7 +599,7 @@
            String arrive = null;
            String alertMessage = null;
            String category1= '3400PK:PK针 5mm×33cm';
            String category1 = '3400PK:PK针 5mm×33cm';
            String Category3 = '腹腔镜手术';
            String Category4 = 'PK';
            String Category5 = 'G400';
@@ -538,69 +635,278 @@
            optionMap.put('', '-无-');
            optionMap.put('ishos', '医院特价产品');
            optionMap.put('nothos', '非医院特价产品');
            Integer count = LexSummonsCreatController.consumableorderdetailsCount;
            Consumable_order__c cocOrderId = new Consumable_order__c();
            LexSummonsCreatController.coc = cocOrderId;
            String consumableorderId = LexSummonsCreatController.consumableorderId;
            LexSummonsCreatController summonCC = new LexSummonsCreatController();
            LexSummonsCreatController.init(testList1.Id,'Test',1,100,testList1.Id);
            LexSummonsCreatController.init(testList1.Id, 'Test', 1, 100, testList1.Id);
            LexSummonsCreatController.firstInit(ESetId);
            LexSummonsCreatController.init(ESetId,statusEdit,1,100,arrive);
            LexSummonsCreatController.init(ESetId,statusEdit,1,100,createIdSend.Id);
            LexSummonsCreatController.init(createIdSend.Id,statusEdit,1,100,arrive);
            LexSummonsCreatController.init(createIdSend.Id,'Test',1,100,createIdSend3.Id);
            LexSummonsCreatController.init(ESetId,'Test',1,100,createIdSend.Id);
            LexSummonsCreatController.searchConsumableorderdetails('ENG','Testaccount001','北京','ishos','Test07','CDS','OER','Celon',true,pageRecords,consumable,'',1,100);
            LexSummonsCreatController.searchConsumableorderdetails('ENG','Testaccount001','北京','nothos','Test07','CDS','OER','Celon',true,pageRecords,consumable,'',1,100);
            LexSummonsCreatController.save(createIdSend2,'','','',pageRecordsLwcLwc,accountId,createIdSend2.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend1,'','','Test',pageRecordsLwcLwc,accountId,createIdSend1.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend1,'Test','Test','Test',pageRecordsLwcLwc,accountId,createIdSend1.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend7,'','',accountItem1.Id,pageRecordsLwcLwc,accountId,createIdSend7.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend,'Test','Test','Test',pageRecordsLwcLwc,accountId,createIdSend.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend3,'Test','Test','',pageRecordsLwcLwc,accountId,createIdSend3.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend3,'','','Test',pageRecordsLwcLwc,accountId,createIdSend3.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend3,'Test','Test','Test',pageRecordsLwcLwc,accountId,createIdSend3.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend4,'','','',pageRecordsLwcLwc,accountId,createIdSend4.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend5,'','','',pageRecordsLwcLwc,accountId,createIdSend5.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend5,'','','Test',pageRecordsLwcLwc,accountId,createIdSend5.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend5,'Test','Test','Test',pageRecordsLwcLwc,accountId,createIdSend5.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend8,accountId,'Test',accountId,pageRecords,accountId,createIdSend8.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend8,accountId,'Test',null,pageRecordsLwc,accountId,createIdSend8.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.init(ESetId, statusEdit, 1, 100, arrive);
            LexSummonsCreatController.init(ESetId, statusEdit, 1, 100, createIdSend.Id);
            LexSummonsCreatController.init(createIdSend.Id, statusEdit, 1, 100, arrive);
            LexSummonsCreatController.init(createIdSend.Id, 'Test', 1, 100, createIdSend3.Id);
            LexSummonsCreatController.init(ESetId, 'Test', 1, 100, createIdSend.Id);
            LexSummonsCreatController.searchConsumableorderdetails(
                'ENG',
                'Testaccount001',
                '北京',
                'ishos',
                'Test07',
                'CDS',
                'OER',
                'Celon',
                true,
                pageRecords,
                consumable,
                '',
                1,
                100
            );
            LexSummonsCreatController.searchConsumableorderdetails(
                'ENG',
                'Testaccount001',
                '北京',
                'nothos',
                'Test07',
                'CDS',
                'OER',
                'Celon',
                true,
                pageRecords,
                consumable,
                '',
                1,
                100
            );
            LexSummonsCreatController.save(
                createIdSend2,
                '',
                '',
                '',
                pageRecordsLwcLwc,
                accountId,
                createIdSend2.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend1,
                '',
                '',
                'Test',
                pageRecordsLwcLwc,
                accountId,
                createIdSend1.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend1,
                'Test',
                'Test',
                'Test',
                pageRecordsLwcLwc,
                accountId,
                createIdSend1.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend7,
                '',
                '',
                accountItem1.Id,
                pageRecordsLwcLwc,
                accountId,
                createIdSend7.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend,
                'Test',
                'Test',
                'Test',
                pageRecordsLwcLwc,
                accountId,
                createIdSend.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend3,
                'Test',
                'Test',
                '',
                pageRecordsLwcLwc,
                accountId,
                createIdSend3.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend3,
                '',
                '',
                'Test',
                pageRecordsLwcLwc,
                accountId,
                createIdSend3.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend3,
                'Test',
                'Test',
                'Test',
                pageRecordsLwcLwc,
                accountId,
                createIdSend3.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend4,
                '',
                '',
                '',
                pageRecordsLwcLwc,
                accountId,
                createIdSend4.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend5,
                '',
                '',
                '',
                pageRecordsLwcLwc,
                accountId,
                createIdSend5.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend5,
                '',
                '',
                'Test',
                pageRecordsLwcLwc,
                accountId,
                createIdSend5.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend5,
                'Test',
                'Test',
                'Test',
                pageRecordsLwcLwc,
                accountId,
                createIdSend5.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend8,
                accountId,
                'Test',
                accountId,
                pageRecords,
                accountId,
                createIdSend8.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend8,
                accountId,
                'Test',
                null,
                pageRecordsLwc,
                accountId,
                createIdSend8.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.checkOutPattern();
            LexSummonsCreatController.PraseToPDF(createIdSend,createIdSend.Id);
            LexSummonsCreatController.PraseToPDF(createIdSend, createIdSend.Id);
            LexSummonsCreatController.search('Testaccount001');
            LexSummonsCreatController.GoodsDelivery(createIdSend,createIdSend.Id,pageRecordsLwcLwc);
            LexSummonsCreatController.GoodsDelivery(createIdSend3,createIdSend3.Id,pageRecords);
            LexSummonsCreatController.GoodsDelivery(createIdSend1,createIdSend1.Id,pageRecordsLwcLwc);
            LexSummonsCreatController.GoodsDelivery(createIdSend6,createIdSend6.Id,pageRecordsLwcLwc);
            LexSummonsCreatController.GoodsDelivery(createIdSend, createIdSend.Id, pageRecordsLwcLwc);
            LexSummonsCreatController.GoodsDelivery(createIdSend3, createIdSend3.Id, pageRecords);
            LexSummonsCreatController.GoodsDelivery(createIdSend1, createIdSend1.Id, pageRecordsLwcLwc);
            LexSummonsCreatController.GoodsDelivery(createIdSend6, createIdSend6.Id, pageRecordsLwcLwc);
            LexSummonsCreatController.DelConsumable(createIdSend.Id);
            System.Test.stopTest();
        }
    }
    @isTest
    static void testSaveMethod(){
    static void testSaveMethod() {
        Account accountItem1;
        Account accountItem2;
        User userTest;
        String rectCo = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
        String rectHp = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
        Profile prof = [SELECT Id FROM Profile WHERE Name ='901_经销商社区普通权限_2重验证(ET)'];
        accountItem1 = new Account(Name='Testaccount001',RecordTypeId = rectCo, AgentCode_Ext__c = '9999900');
        Profile prof = [SELECT Id FROM Profile WHERE Name = '901_经销商社区普通权限_2重验证(ET)'];
        accountItem1 = new Account(Name = 'Testaccount001', RecordTypeId = rectCo, AgentCode_Ext__c = '9999900');
        insert accountItem1;
        accountItem2 = new Account(Name='Testaccount002',RecordTypeId = rectHp, AgentCode_Ext__c = '9999999', ParentId = accountItem1.Id,Contract_Decide_Start_Date__c = Date.today(),ENG_Dealer__c = true,BillingCity = null);
        accountItem2 = new Account(
            Name = 'Testaccount002',
            RecordTypeId = rectHp,
            AgentCode_Ext__c = '9999999',
            ParentId = accountItem1.Id,
            Contract_Decide_Start_Date__c = Date.today(),
            ENG_Dealer__c = true,
            BillingCity = null
        );
        insert accountItem2;
        Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe', lastname='Plumber', accountId = accountItem1.Id);
        Contact core = new Contact(email = 'jplumber@salesforce.com', firstname = 'Joe', lastname = 'Plumber', accountId = accountItem1.Id);
        insert core;
        System.runAs(new user(ID = UserInfo.getUserID())) {
            userTest = New User(ContactId = core.id, Alias = 'newUser', Email='newuser@testorg.com', EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN', LocaleSidKey='zh_CN', ProfileId = prof.Id, TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com', UserPro_Type__c='ENG', Work_Location__c='北京');
            userTest = new User(
                ContactId = core.id,
                Alias = 'newUser',
                Email = 'newuser@testorg.com',
                EmailEncodingKey = 'UTF-8',
                LastName = 'TestUser',
                LanguageLocaleKey = 'zh_CN',
                LocaleSidKey = 'zh_CN',
                ProfileId = prof.Id,
                TimeZoneSidKey = 'Asia/Shanghai',
                UserName = 'testUser@testorg.com',
                UserPro_Type__c = 'ENG',
                Work_Location__c = '北京'
            );
            insert userTest;
        }
        System.runAs(userTest){
        System.runAs(userTest) {
            String userId = UserInfo.getUserId();
            User thisUserInfo = [SELECT accountid, UserPro_Type__c, ContactId, Contact.AccountId,Contact.Account.Name, Work_Location__c FROM User WHERE id =:userId];
            User thisUserInfo = [
                SELECT accountid, UserPro_Type__c, ContactId, Contact.AccountId, Contact.Account.Name, Work_Location__c
                FROM User
                WHERE id = :userId
            ];
            String accountId = thisUserInfo.accountid;
            String accountName = thisUserInfo.Contact.Account.Name;
            String agencyProType = thisUserInfo.UserPro_Type__c;
@@ -610,10 +916,28 @@
            if (String.isBlank(thisUserInfo.UserPro_Type__c)) {
                agencyProType = 'ET';
            }
           Product2 prod07 = new Product2(Name='Test07',ProductCode='Test07',Asset_Model_No__c = 'Test07',Category3__c = 'Test7',Category4__c = 'Test77',Category5__c = 'Test777',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false);
           insert new Product2[] {prod07};
            Product2__c pro1 = new Product2__c(Name='MH-155:白平衡帽',OT_CODE_Text__c='Test001',Product2__c = prod07.Id,Category3_text__c = 'test123', Category4_text__c = 'test123', Category5_text__c = 'test123');
         insert new Product2__c[] {pro1};
            Product2 prod07 = new Product2(
                Name = 'Test07',
                ProductCode = 'Test07',
                Asset_Model_No__c = 'Test07',
                Category3__c = 'Test7',
                Category4__c = 'Test77',
                Category5__c = 'Test777',
                SFDA_Status__c = '有効',
                Dealer_special_Object__c = true,
                Packing_list_manual__c = 1,
                Manual_Entry__c = false
            );
            insert new List<Product2>{ prod07 };
            Product2__c pro1 = new Product2__c(
                Name = 'MH-155:白平衡帽',
                OT_CODE_Text__c = 'Test001',
                Product2__c = prod07.Id,
                Category3_text__c = 'test123',
                Category4_text__c = 'test123',
                Category5_text__c = 'test123'
            );
            insert new List<Product2__c>{ pro1 };
            Consumable_order__c createIdSend = new Consumable_order__c();
            createIdSend.Name = 'testMing1';
            createIdSend.Order_status__c = '批准';
@@ -641,8 +965,8 @@
            createIdSend1.SummonsStatus_c__c = '价格未定';
            createIdSend1.Dealer_Info__c = accountItem1.Id;
            createIdSend1.Delivery_detail_count__c = 5;
            insert new Consumable_order__c[]{createIdSend,createIdSend1};
            insert new List<Consumable_order__c>{ createIdSend, createIdSend1 };
            Consumable_orderdetails__c coc = new Consumable_orderdetails__c();
            coc.Name = 'Too001';
            coc.Dealer_Custom_Price__c = 999.00;
@@ -694,7 +1018,7 @@
            coc3.Delivery_List_RMB__c = 100.00;
            coc3.Shipment_Count__c = 9999.00;
            coc3.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
            insert new Consumable_orderdetails__c[]{coc,coc1,coc2,coc3};
            insert new List<Consumable_orderdetails__c>{ coc, coc1, coc2, coc3 };
            Consumable_order_details2__c conOrderDetail1 = new Consumable_order_details2__c();
            conOrderDetail1.Name = 'OCM_01_001001';
@@ -711,8 +1035,7 @@
            conOrderDetail1.Cancellation_Flag__c = false;
            conOrderDetail1.Box_Piece__c = '盒';
            conOrderDetail1.Sterilization_limit__c = Date.Today();
            insert new Consumable_order_details2__c[]{conOrderDetail1};
            insert new List<Consumable_order_details2__c>{ conOrderDetail1 };
            List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecords = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
            LexSummonsCreatController.ConsumableorderdetailsInfoLwc c0 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
@@ -868,39 +1191,130 @@
            codi.boxorpiecein = null;
            codi.orderdetails1 = coc;
            codi.Prod = pro1;
            consumable.add(codi);
            consumable.add(codi);
            System.Test.startTest();
            LexSummonsCreatController.save(createIdSend,'','','',pageRecords,accountId,createIdSend.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend,'','','',pageRecords1,accountId,createIdSend.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend,'','','',pageRecords2,accountId,createIdSend.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend,'','','',pageRecords3,accountId,createIdSend.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend,'','','',pageRecords0,accountId,createIdSend.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend,'','','',pageRecords4,accountId,createIdSend.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(
                createIdSend,
                '',
                '',
                '',
                pageRecords,
                accountId,
                createIdSend.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend,
                '',
                '',
                '',
                pageRecords1,
                accountId,
                createIdSend.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend,
                '',
                '',
                '',
                pageRecords2,
                accountId,
                createIdSend.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend,
                '',
                '',
                '',
                pageRecords3,
                accountId,
                createIdSend.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend,
                '',
                '',
                '',
                pageRecords0,
                accountId,
                createIdSend.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend,
                '',
                '',
                '',
                pageRecords4,
                accountId,
                createIdSend.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            System.Test.stopTest();
        }
    }
    @isTest
    static void testSaveMethod1(){
    static void testSaveMethod1() {
        Account accountItem1;
        Account accountItem2;
        User userTest;
        String rectCo = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
        String rectHp = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
        Profile prof = [SELECT Id FROM Profile WHERE Name ='901_经销商社区普通权限_2重验证(ET)'];
        accountItem1 = new Account(Name='Testaccount001',RecordTypeId = rectCo, AgentCode_Ext__c = '9999900');
        Profile prof = [SELECT Id FROM Profile WHERE Name = '901_经销商社区普通权限_2重验证(ET)'];
        accountItem1 = new Account(Name = 'Testaccount001', RecordTypeId = rectCo, AgentCode_Ext__c = '9999900');
        insert accountItem1;
        accountItem2 = new Account(Name='Testaccount002',RecordTypeId = rectHp, AgentCode_Ext__c = '9999999', ParentId = accountItem1.Id,Contract_Decide_Start_Date__c = Date.today(),ENG_Dealer__c = true,BillingCity = null);
        accountItem2 = new Account(
            Name = 'Testaccount002',
            RecordTypeId = rectHp,
            AgentCode_Ext__c = '9999999',
            ParentId = accountItem1.Id,
            Contract_Decide_Start_Date__c = Date.today(),
            ENG_Dealer__c = true,
            BillingCity = null
        );
        insert accountItem2;
        Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe', lastname='Plumber', accountId = accountItem1.Id);
        Contact core = new Contact(email = 'jplumber@salesforce.com', firstname = 'Joe', lastname = 'Plumber', accountId = accountItem1.Id);
        insert core;
        System.runAs(new user(ID = UserInfo.getUserID())) {
            userTest = New User(ContactId = core.id, Alias = 'newUser', Email='newuser@testorg.com', EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN', LocaleSidKey='zh_CN', ProfileId = prof.Id, TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com', UserPro_Type__c='ENG', Work_Location__c='北京');
            userTest = new User(
                ContactId = core.id,
                Alias = 'newUser',
                Email = 'newuser@testorg.com',
                EmailEncodingKey = 'UTF-8',
                LastName = 'TestUser',
                LanguageLocaleKey = 'zh_CN',
                LocaleSidKey = 'zh_CN',
                ProfileId = prof.Id,
                TimeZoneSidKey = 'Asia/Shanghai',
                UserName = 'testUser@testorg.com',
                UserPro_Type__c = 'ENG',
                Work_Location__c = '北京'
            );
            insert userTest;
        }
        System.runAs(userTest){
        System.runAs(userTest) {
            String userId = UserInfo.getUserId();
            User thisUserInfo = [SELECT accountid, UserPro_Type__c, ContactId, Contact.AccountId,Contact.Account.Name, Work_Location__c FROM User WHERE id =:userId];
            User thisUserInfo = [
                SELECT accountid, UserPro_Type__c, ContactId, Contact.AccountId, Contact.Account.Name, Work_Location__c
                FROM User
                WHERE id = :userId
            ];
            String accountId = thisUserInfo.accountid;
            String accountName = thisUserInfo.Contact.Account.Name;
            String agencyProType = thisUserInfo.UserPro_Type__c;
@@ -910,11 +1324,31 @@
            if (String.isBlank(thisUserInfo.UserPro_Type__c)) {
                agencyProType = 'ET';
            }
           Product2 prod07 = new Product2(Name='Test07',ProductCode='Test07',Asset_Model_No__c = 'Test07',Category3__c = 'Test7',Category4__c = 'Test77',Category5__c = 'Test777',SFDA_Status__c = '有効',
                                            Intra_Trade_List_RMB_End_Date1__c = Date.Today(),Intra_Trade_List_RMB_Date2__c = null ,Intra_Trade_List_RMB_1__c = 1,Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false);
           insert new Product2[] {prod07};
            Product2__c pro1 = new Product2__c(Name='MH-155:白平衡帽',OT_CODE_Text__c='Test001',Product2__c = prod07.Id,Category3_text__c = 'test123', Category4_text__c = 'test123', Category5_text__c = 'test123');
         insert new Product2__c[] {pro1};
            Product2 prod07 = new Product2(
                Name = 'Test07',
                ProductCode = 'Test07',
                Asset_Model_No__c = 'Test07',
                Category3__c = 'Test7',
                Category4__c = 'Test77',
                Category5__c = 'Test777',
                SFDA_Status__c = '有効',
                Intra_Trade_List_RMB_End_Date1__c = Date.Today(),
                Intra_Trade_List_RMB_Date2__c = null,
                Intra_Trade_List_RMB_1__c = 1,
                Dealer_special_Object__c = true,
                Packing_list_manual__c = 1,
                Manual_Entry__c = false
            );
            insert new List<Product2>{ prod07 };
            Product2__c pro1 = new Product2__c(
                Name = 'MH-155:白平衡帽',
                OT_CODE_Text__c = 'Test001',
                Product2__c = prod07.Id,
                Category3_text__c = 'test123',
                Category4_text__c = 'test123',
                Category5_text__c = 'test123'
            );
            insert new List<Product2__c>{ pro1 };
            Consumable_order__c createIdSend = new Consumable_order__c();
            createIdSend.Name = 'testMing1';
            createIdSend.Order_status__c = '批准';
@@ -942,8 +1376,8 @@
            createIdSend1.SummonsStatus_c__c = '价格未定';
            createIdSend1.Dealer_Info__c = accountItem1.Id;
            createIdSend1.Delivery_detail_count__c = 5;
            insert new Consumable_order__c[]{createIdSend,createIdSend1};
            insert new List<Consumable_order__c>{ createIdSend, createIdSend1 };
            Consumable_orderdetails__c coc = new Consumable_orderdetails__c();
            coc.Name = 'Too001';
            coc.Dealer_Custom_Price__c = 999.00;
@@ -1042,7 +1476,7 @@
            coc7.Delivery_List_RMB__c = 100;
            coc7.Shipment_Count__c = 0;
            coc7.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
            insert new Consumable_orderdetails__c[]{coc,coc1,coc2,coc3,coc4,coc5,coc6,coc7};
            insert new List<Consumable_orderdetails__c>{ coc, coc1, coc2, coc3, coc4, coc5, coc6, coc7 };
            Consumable_order_details2__c conOrderDetail1 = new Consumable_order_details2__c();
            conOrderDetail1.Name = 'OCM_01_001001';
@@ -1059,7 +1493,7 @@
            conOrderDetail1.Cancellation_Flag__c = false;
            conOrderDetail1.Box_Piece__c = '盒';
            conOrderDetail1.Sterilization_limit__c = Date.Today();
            insert new Consumable_order_details2__c[]{conOrderDetail1};
            insert new List<Consumable_order_details2__c>{ conOrderDetail1 };
            List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecords = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
            LexSummonsCreatController.ConsumableorderdetailsInfoLwc c0 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
            c0.check = true;
@@ -1166,37 +1600,109 @@
            codi.boxorpiecein = null;
            codi.orderdetails1 = coc;
            codi.Prod = pro1;
            consumable.add(codi);
            consumable.add(codi);
            System.Test.startTest();
            LexSummonsCreatController.save(createIdSend,'','','',pageRecords,accountId,createIdSend.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend,'','','',pageRecords1,accountId,createIdSend.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend,'','','',pageRecords2,accountId,createIdSend.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend,'','','',pageRecords3,accountId,createIdSend.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(
                createIdSend,
                '',
                '',
                '',
                pageRecords,
                accountId,
                createIdSend.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend,
                '',
                '',
                '',
                pageRecords1,
                accountId,
                createIdSend.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend,
                '',
                '',
                '',
                pageRecords2,
                accountId,
                createIdSend.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend,
                '',
                '',
                '',
                pageRecords3,
                accountId,
                createIdSend.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            System.Test.stopTest();
        }
    }
    @isTest
    static void testSave(){
    static void testSave() {
        Account accountItem1;
        Account accountItem2;
        User userTest;
        String rectCo = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
        String rectHp = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
        Profile prof = [SELECT Id FROM Profile WHERE Name ='901_经销商社区普通权限_2重验证(ET)'];
        accountItem1 = new Account(Name='Testaccount001',RecordTypeId = rectCo, AgentCode_Ext__c = '9999900',Contract_Decide_Start_Date__c = Date.today(),ENG_Dealer__c = true);
        Profile prof = [SELECT Id FROM Profile WHERE Name = '901_经销商社区普通权限_2重验证(ET)'];
        accountItem1 = new Account(
            Name = 'Testaccount001',
            RecordTypeId = rectCo,
            AgentCode_Ext__c = '9999900',
            Contract_Decide_Start_Date__c = Date.today(),
            ENG_Dealer__c = true
        );
        insert accountItem1;
        accountItem2 = new Account(Name='Testaccount002',RecordTypeId = rectHp, AgentCode_Ext__c = '9999999', ParentId = accountItem1.Id);
        accountItem2 = new Account(
            Name = 'Testaccount002',
            RecordTypeId = rectHp,
            AgentCode_Ext__c = '9999999',
            ParentId = accountItem1.Id
        );
        insert accountItem2;
        Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe', lastname='Plumber', accountId = accountItem1.Id);
        Contact core = new Contact(email = 'jplumber@salesforce.com', firstname = 'Joe', lastname = 'Plumber', accountId = accountItem1.Id);
        insert core;
        System.runAs(new user(ID = UserInfo.getUserID())) {
            userTest = New User(ContactId = core.id, Alias = 'newUser', Email='newuser@testorg.com', EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN', LocaleSidKey='zh_CN', ProfileId = prof.Id, TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com', UserPro_Type__c='ENG', Work_Location__c='北京');
            userTest = new User(
                ContactId = core.id,
                Alias = 'newUser',
                Email = 'newuser@testorg.com',
                EmailEncodingKey = 'UTF-8',
                LastName = 'TestUser',
                LanguageLocaleKey = 'zh_CN',
                LocaleSidKey = 'zh_CN',
                ProfileId = prof.Id,
                TimeZoneSidKey = 'Asia/Shanghai',
                UserName = 'testUser@testorg.com',
                UserPro_Type__c = 'ENG',
                Work_Location__c = '北京'
            );
            insert userTest;
        }
        System.runAs(userTest){
        System.runAs(userTest) {
            String userId = UserInfo.getUserId();
            User thisUserInfo = [SELECT accountid, UserPro_Type__c, ContactId, Contact.AccountId,Contact.Account.Name, Work_Location__c FROM User WHERE id =:userId];
            User thisUserInfo = [
                SELECT accountid, UserPro_Type__c, ContactId, Contact.AccountId, Contact.Account.Name, Work_Location__c
                FROM User
                WHERE id = :userId
            ];
            String accountId = thisUserInfo.accountid;
            String accountName = thisUserInfo.Contact.Account.Name;
            String agencyProType = thisUserInfo.UserPro_Type__c;
@@ -1206,10 +1712,28 @@
            if (String.isBlank(thisUserInfo.UserPro_Type__c)) {
                agencyProType = 'ET';
            }
           Product2 prod07 = new Product2(Name='Test07',ProductCode='Test07',Asset_Model_No__c = 'Test07',Category3__c = 'Test7',Category4__c = 'Test77',Category5__c = 'Test777',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false);
           insert new Product2[] {prod07};
            Product2__c pro1 = new Product2__c(Name='MH-155:白平衡帽',OT_CODE_Text__c='Test001',Product2__c = prod07.Id,Category3_text__c = 'test123', Category4_text__c = 'test123', Category5_text__c = 'test123');
         insert new Product2__c[] {pro1};
            Product2 prod07 = new Product2(
                Name = 'Test07',
                ProductCode = 'Test07',
                Asset_Model_No__c = 'Test07',
                Category3__c = 'Test7',
                Category4__c = 'Test77',
                Category5__c = 'Test777',
                SFDA_Status__c = '有効',
                Dealer_special_Object__c = true,
                Packing_list_manual__c = 1,
                Manual_Entry__c = false
            );
            insert new List<Product2>{ prod07 };
            Product2__c pro1 = new Product2__c(
                Name = 'MH-155:白平衡帽',
                OT_CODE_Text__c = 'Test001',
                Product2__c = prod07.Id,
                Category3_text__c = 'test123',
                Category4_text__c = 'test123',
                Category5_text__c = 'test123'
            );
            insert new List<Product2__c>{ pro1 };
            Consumable_order__c createIdSend = new Consumable_order__c();
            createIdSend.Name = 'testMing1';
@@ -1255,7 +1779,7 @@
            createIdSend2.SummonsStatus_c__c = '价格未定';
            createIdSend2.Dealer_Info__c = accountItem1.Id;
            createIdSend2.Delivery_detail_count__c = 5;
            insert new Consumable_order__c[] {createIdSend,createIdSend1,createIdSend2};
            insert new List<Consumable_order__c>{ createIdSend, createIdSend1, createIdSend2 };
            Consumable_orderdetails__c coc = new Consumable_orderdetails__c();
            coc.Name = 'Too001';
@@ -1329,7 +1853,7 @@
            coc5.Delivery_List_RMB__c = 100;
            coc5.Shipment_Count__c = 10000;
            coc5.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
            insert new Consumable_orderdetails__c[]{coc,coc1,coc2,coc3,coc4,coc5};
            insert new List<Consumable_orderdetails__c>{ coc, coc1, coc2, coc3, coc4, coc5 };
            Consumable_order_details2__c conOrderDetail1 = new Consumable_order_details2__c();
            conOrderDetail1.Name = 'OCM_01_001001';
@@ -1344,13 +1868,13 @@
            conOrderDetail1.Consumable_order_minor__c = createIdSend.Id;
            conOrderDetail1.Lose_Flag__c = false;
            conOrderDetail1.Box_Piece__c = '盒';
            insert new Consumable_order_details2__c[]{conOrderDetail1};
            insert new List<Consumable_order_details2__c>{ conOrderDetail1 };
            hospitalprice__c hp1 = new hospitalprice__c();
            hp1.hospital__c = accountId;
            hp1.account__c = accountId;
            hp1.product__c = pro1.Id;
            insert new hospitalprice__c[]{hp1};
            insert new List<hospitalprice__c>{ hp1 };
            List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecordsList = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
            LexSummonsCreatController.ConsumableorderdetailsInfoLwc cod = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
@@ -1478,41 +2002,157 @@
            String arrive = createIdSend.Id;
            System.Test.startTest();
            LexSummonsCreatController.firstInit(ESetId);
            LexSummonsCreatController.init(ESetId,statusEdit,1,100,arrive);
            LexSummonsCreatController.init(ESetId,null,1,100,arrive);
            LexSummonsCreatController.GoodsDelivery(createIdSend2,createIdSend2.Id,pageRecords);
            LexSummonsCreatController.save(createIdSend,accountId,'Test',accountItem1.Id,pageRecordsList,accountId,createIdSend.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend,accountId,'Test',accountItem1.Id,pageRecords,accountId,createIdSend.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend,accountId,'Test',accountItem1.Id,null,accountId,createIdSend.Id,null,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend,accountId,'Test',accountItem1.Id,pageRecords,accountId,null,consumableList,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend2,accountId,'Test',null,pageRecords,accountId,createIdSend2.Id,null,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend2,accountId,'Test',null,pageRecords2,accountId,createIdSend2.Id,null,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend2,accountId,'Test',null,pageRecords3,accountId,createIdSend2.Id,null,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend1,'','',accountItem1.Id,pageRecords3,accountId,createIdSend2.Id,null,agencyProType,userWorkLocation);
            LexSummonsCreatController.init(ESetId, statusEdit, 1, 100, arrive);
            LexSummonsCreatController.init(ESetId, null, 1, 100, arrive);
            LexSummonsCreatController.GoodsDelivery(createIdSend2, createIdSend2.Id, pageRecords);
            LexSummonsCreatController.save(
                createIdSend,
                accountId,
                'Test',
                accountItem1.Id,
                pageRecordsList,
                accountId,
                createIdSend.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend,
                accountId,
                'Test',
                accountItem1.Id,
                pageRecords,
                accountId,
                createIdSend.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend,
                accountId,
                'Test',
                accountItem1.Id,
                null,
                accountId,
                createIdSend.Id,
                null,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend,
                accountId,
                'Test',
                accountItem1.Id,
                pageRecords,
                accountId,
                null,
                consumableList,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend2,
                accountId,
                'Test',
                null,
                pageRecords,
                accountId,
                createIdSend2.Id,
                null,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend2,
                accountId,
                'Test',
                null,
                pageRecords2,
                accountId,
                createIdSend2.Id,
                null,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend2,
                accountId,
                'Test',
                null,
                pageRecords3,
                accountId,
                createIdSend2.Id,
                null,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend1,
                '',
                '',
                accountItem1.Id,
                pageRecords3,
                accountId,
                createIdSend2.Id,
                null,
                agencyProType,
                userWorkLocation
            );
            System.Test.stopTest();
        }
    }
    @isTest
    static void testAttachment(){
    static void testAttachment() {
        Account accountItem1;
        Account accountItem2;
        User userTest;
        String rectCo = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
        String rectHp = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
        Profile prof = [SELECT Id FROM Profile WHERE Name ='901_经销商社区普通权限_2重验证(ET)'];
        accountItem1 = new Account(Name='Testaccount001',RecordTypeId = rectCo, AgentCode_Ext__c = '9999900',Contract_Decide_Start_Date__c = Date.today(),ENG_Dealer__c = true);
        Profile prof = [SELECT Id FROM Profile WHERE Name = '901_经销商社区普通权限_2重验证(ET)'];
        accountItem1 = new Account(
            Name = 'Testaccount001',
            RecordTypeId = rectCo,
            AgentCode_Ext__c = '9999900',
            Contract_Decide_Start_Date__c = Date.today(),
            ENG_Dealer__c = true
        );
        insert accountItem1;
        accountItem2 = new Account(Name='Testaccount002',RecordTypeId = rectHp, AgentCode_Ext__c = '9999999', ParentId = accountItem1.Id);
        accountItem2 = new Account(
            Name = 'Testaccount002',
            RecordTypeId = rectHp,
            AgentCode_Ext__c = '9999999',
            ParentId = accountItem1.Id
        );
        insert accountItem2;
        Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe', lastname='Plumber', accountId = accountItem1.Id);
        Contact core = new Contact(email = 'jplumber@salesforce.com', firstname = 'Joe', lastname = 'Plumber', accountId = accountItem1.Id);
        insert core;
        System.runAs(new user(ID = UserInfo.getUserID())) {
            userTest = New User(ContactId = core.id, Alias = 'newUser', Email='newuser@testorg.com', EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN', LocaleSidKey='zh_CN', ProfileId = prof.Id, TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com', UserPro_Type__c='ENG', Work_Location__c='北京');
            userTest = new User(
                ContactId = core.id,
                Alias = 'newUser',
                Email = 'newuser@testorg.com',
                EmailEncodingKey = 'UTF-8',
                LastName = 'TestUser',
                LanguageLocaleKey = 'zh_CN',
                LocaleSidKey = 'zh_CN',
                ProfileId = prof.Id,
                TimeZoneSidKey = 'Asia/Shanghai',
                UserName = 'testUser@testorg.com',
                UserPro_Type__c = 'ENG',
                Work_Location__c = '北京'
            );
            insert userTest;
        }
        System.runAs(userTest){
        System.runAs(userTest) {
            String userId = UserInfo.getUserId();
            User thisUserInfo = [SELECT accountid, UserPro_Type__c, ContactId, Contact.AccountId,Contact.Account.Name, Work_Location__c FROM User WHERE id =:userId];
            User thisUserInfo = [
                SELECT accountid, UserPro_Type__c, ContactId, Contact.AccountId, Contact.Account.Name, Work_Location__c
                FROM User
                WHERE id = :userId
            ];
            String accountId = thisUserInfo.accountid;
            String accountName = thisUserInfo.Contact.Account.Name;
            String agencyProType = thisUserInfo.UserPro_Type__c;
@@ -1522,10 +2162,28 @@
            if (String.isBlank(thisUserInfo.UserPro_Type__c)) {
                agencyProType = 'ET';
            }
           Product2 prod07 = new Product2(Name='Test07',ProductCode='Test07',Asset_Model_No__c = 'Test07',Category3__c = 'Test7',Category4__c = 'Test77',Category5__c = 'Test777',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false);
           insert new Product2[] {prod07};
            Product2__c pro1 = new Product2__c(Name='MH-155:白平衡帽',OT_CODE_Text__c='Test001',Product2__c = prod07.Id,Category3_text__c = 'test123', Category4_text__c = 'test123', Category5_text__c = 'test123');
         insert new Product2__c[] {pro1};
            Product2 prod07 = new Product2(
                Name = 'Test07',
                ProductCode = 'Test07',
                Asset_Model_No__c = 'Test07',
                Category3__c = 'Test7',
                Category4__c = 'Test77',
                Category5__c = 'Test777',
                SFDA_Status__c = '有効',
                Dealer_special_Object__c = true,
                Packing_list_manual__c = 1,
                Manual_Entry__c = false
            );
            insert new List<Product2>{ prod07 };
            Product2__c pro1 = new Product2__c(
                Name = 'MH-155:白平衡帽',
                OT_CODE_Text__c = 'Test001',
                Product2__c = prod07.Id,
                Category3_text__c = 'test123',
                Category4_text__c = 'test123',
                Category5_text__c = 'test123'
            );
            insert new List<Product2__c>{ pro1 };
            //发货
            Consumable_order__c createIdSend = new Consumable_order__c();
            createIdSend.Name = 'testMing1';
@@ -1568,7 +2226,7 @@
            createIdSend2.SummonsStatus_c__c = '批准';
            createIdSend2.Dealer_Info__c = accountItem1.Id;
            createIdSend2.Delivery_detail_count__c = 5;
            insert new Consumable_order__c[] {createIdSend,createIdSend1,createIdSend2};
            insert new List<Consumable_order__c>{ createIdSend, createIdSend1, createIdSend2 };
            Consumable_orderdetails__c coc = new Consumable_orderdetails__c();
            coc.Name = 'Too001';
@@ -1594,7 +2252,7 @@
            coc2.Delivery_List_RMB__c = 0;
            coc2.Shipment_Count__c = 0;
            coc2.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
            insert new Consumable_orderdetails__c[]{coc,coc2};
            insert new List<Consumable_orderdetails__c>{ coc, coc2 };
            Consumable_order_details2__c conOrderDetail1 = new Consumable_order_details2__c();
            conOrderDetail1.Name = 'OCM_01_001001';
@@ -1609,21 +2267,21 @@
            conOrderDetail1.Consumable_order_minor__c = createIdSend.Id;
            conOrderDetail1.Lose_Flag__c = false;
            conOrderDetail1.Box_Piece__c = '盒';
            insert new Consumable_order_details2__c[]{conOrderDetail1};
            insert new List<Consumable_order_details2__c>{ conOrderDetail1 };
            hospitalprice__c hp1 = new hospitalprice__c();
            hp1.hospital__c = accountId;
            hp1.account__c = accountId;
            hp1.product__c = pro1.Id;
            insert new hospitalprice__c[]{hp1};
            insert new List<hospitalprice__c>{ hp1 };
            Attachment attach = new Attachment();
            attach.Name='A-65224941-20200923--1.docx';
            Blob bodyBlob= Blob.valueOf('Unit Test Attachment Body');
            Attachment attach = new Attachment();
            attach.Name = 'A-65224941-20200923--1.docx';
            Blob bodyBlob = Blob.valueOf('Unit Test Attachment Body');
            attach.body = bodyBlob;
            attach.ParentId = createIdSend.id;
            attach.ContentType = 'application/pdf';
            insert new Attachment[] {attach};
            insert new List<Attachment>{ attach };
            System.Test.startTest();
            List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecordsLwcLwc = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
@@ -1633,7 +2291,7 @@
            c5.orderdetails1 = coc;
            c5.allnumber = 1999.00;
            pageRecordsLwcLwc.add(c5);
            List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecordsList= new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
            List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecordsList = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
            LexSummonsCreatController.ConsumableorderdetailsInfoLwc c8 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
            c8.check = true;
            c8.hospitalSpecialOffer = true;
@@ -1700,12 +2358,71 @@
            String statusEdit = 'Test';
            String arrive = createIdSend.Id;
            LexSummonsCreatController.firstInit(ESetId);
            LexSummonsCreatController.init(ESetId,statusEdit,1,100,arrive);
            LexSummonsCreatController.save(createIdSend,'Test','Test','Test',pageRecordsLwc,accountId,createIdSend.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend1,'Test','Test','Test',pageRecordsLwc,accountId,createIdSend1.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend2,'','','',pageRecordsLwc,accountId,createIdSend2.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend,'','','',pageRecordsList,accountId,null,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.searchConsumableorderdetails(agencyProType,accountName,userWorkLocation,'ishos','Test07','Test7','Test77','Test777',true,pageRecordsLwc,consumable,'',1,100);
            LexSummonsCreatController.init(ESetId, statusEdit, 1, 100, arrive);
            LexSummonsCreatController.save(
                createIdSend,
                'Test',
                'Test',
                'Test',
                pageRecordsLwc,
                accountId,
                createIdSend.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend1,
                'Test',
                'Test',
                'Test',
                pageRecordsLwc,
                accountId,
                createIdSend1.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend2,
                '',
                '',
                '',
                pageRecordsLwc,
                accountId,
                createIdSend2.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend,
                '',
                '',
                '',
                pageRecordsList,
                accountId,
                null,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.searchConsumableorderdetails(
                agencyProType,
                accountName,
                userWorkLocation,
                'ishos',
                'Test07',
                'Test7',
                'Test77',
                'Test777',
                true,
                pageRecordsLwc,
                consumable,
                '',
                1,
                100
            );
            LexSummonsCreatController.ConsumableorderdetailsInfo con = new LexSummonsCreatController.ConsumableorderdetailsInfo(attach);
            con.concc = attach;
            con.hospitalSpecialOffer = false;
@@ -1715,26 +2432,54 @@
    }
    @isTest
    static void testSave1(){
    static void testSave1() {
        Account accountItem1;
        Account accountItem2;
        User userTest;
        String rectCo = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
        String rectHp = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
        Profile prof = [SELECT Id FROM Profile WHERE Name ='901_经销商社区普通权限_2重验证(ET)'];
        accountItem1 = new Account(Name='Testaccount001',RecordTypeId = rectCo, AgentCode_Ext__c = '9999900',Contract_Decide_Start_Date__c = Date.today(),ENG_Dealer__c = true);
        Profile prof = [SELECT Id FROM Profile WHERE Name = '901_经销商社区普通权限_2重验证(ET)'];
        accountItem1 = new Account(
            Name = 'Testaccount001',
            RecordTypeId = rectCo,
            AgentCode_Ext__c = '9999900',
            Contract_Decide_Start_Date__c = Date.today(),
            ENG_Dealer__c = true
        );
        insert accountItem1;
        accountItem2 = new Account(Name='Testaccount002',RecordTypeId = rectHp, AgentCode_Ext__c = '9999999', ParentId = accountItem1.Id);
        accountItem2 = new Account(
            Name = 'Testaccount002',
            RecordTypeId = rectHp,
            AgentCode_Ext__c = '9999999',
            ParentId = accountItem1.Id
        );
        insert accountItem2;
        Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe', lastname='Plumber', accountId = accountItem1.Id);
        Contact core = new Contact(email = 'jplumber@salesforce.com', firstname = 'Joe', lastname = 'Plumber', accountId = accountItem1.Id);
        insert core;
        System.runAs(new user(ID = UserInfo.getUserID())) {
            userTest = New User(ContactId = core.id, Alias = 'newUser', Email='newuser@testorg.com', EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN', LocaleSidKey='zh_CN', ProfileId = prof.Id, TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com', UserPro_Type__c='ENG', Work_Location__c='北京');
            userTest = new User(
                ContactId = core.id,
                Alias = 'newUser',
                Email = 'newuser@testorg.com',
                EmailEncodingKey = 'UTF-8',
                LastName = 'TestUser',
                LanguageLocaleKey = 'zh_CN',
                LocaleSidKey = 'zh_CN',
                ProfileId = prof.Id,
                TimeZoneSidKey = 'Asia/Shanghai',
                UserName = 'testUser@testorg.com',
                UserPro_Type__c = 'ENG',
                Work_Location__c = '北京'
            );
            insert userTest;
        }
        System.runAs(userTest){
        System.runAs(userTest) {
            String userId = UserInfo.getUserId();
            User thisUserInfo = [SELECT accountid, UserPro_Type__c, ContactId, Contact.AccountId,Contact.Account.Name, Work_Location__c FROM User WHERE id =:userId];
            User thisUserInfo = [
                SELECT accountid, UserPro_Type__c, ContactId, Contact.AccountId, Contact.Account.Name, Work_Location__c
                FROM User
                WHERE id = :userId
            ];
            String accountId = thisUserInfo.accountid;
            String accountName = thisUserInfo.Contact.Account.Name;
            String agencyProType = thisUserInfo.UserPro_Type__c;
@@ -1744,10 +2489,28 @@
            if (String.isBlank(thisUserInfo.UserPro_Type__c)) {
                agencyProType = 'ET';
            }
           Product2 prod07 = new Product2(Name='Test07',ProductCode='Test07',Asset_Model_No__c = 'Test07',Category3__c = 'Test7',Category4__c = 'Test77',Category5__c = 'Test777',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false);
           insert new Product2[] {prod07};
            Product2__c pro1 = new Product2__c(Name='MH-155:白平衡帽',OT_CODE_Text__c='Test001',Product2__c = prod07.Id,Category3_text__c = 'test123', Category4_text__c = 'test123', Category5_text__c = 'test123');
         insert new Product2__c[] {pro1};
            Product2 prod07 = new Product2(
                Name = 'Test07',
                ProductCode = 'Test07',
                Asset_Model_No__c = 'Test07',
                Category3__c = 'Test7',
                Category4__c = 'Test77',
                Category5__c = 'Test777',
                SFDA_Status__c = '有効',
                Dealer_special_Object__c = true,
                Packing_list_manual__c = 1,
                Manual_Entry__c = false
            );
            insert new List<Product2>{ prod07 };
            Product2__c pro1 = new Product2__c(
                Name = 'MH-155:白平衡帽',
                OT_CODE_Text__c = 'Test001',
                Product2__c = prod07.Id,
                Category3_text__c = 'test123',
                Category4_text__c = 'test123',
                Category5_text__c = 'test123'
            );
            insert new List<Product2__c>{ pro1 };
            Consumable_order__c createIdSend = new Consumable_order__c();
            createIdSend.Name = 'testMing1';
@@ -1778,7 +2541,7 @@
            createIdSend1.Order_ForDealerTextID__c = accountItem1.Id;
            createIdSend1.Dealer_Info__c = accountItem1.Id;
            createIdSend1.Delivery_detail_count__c = 5;
            insert new Consumable_order__c[] {createIdSend,createIdSend1};
            insert new List<Consumable_order__c>{ createIdSend, createIdSend1 };
            Consumable_orderdetails__c coc = new Consumable_orderdetails__c();
            coc.Name = 'Too001';
@@ -1804,7 +2567,7 @@
            coc1.Delivery_List_RMB__c = null;
            coc1.Shipment_Count__c = 10000;
            coc1.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
            insert new Consumable_orderdetails__c[]{coc,coc1};
            insert new List<Consumable_orderdetails__c>{ coc, coc1 };
            Consumable_order_details2__c conOrderDetail1 = new Consumable_order_details2__c();
            conOrderDetail1.Name = 'OCM_01_001001';
@@ -1819,13 +2582,13 @@
            conOrderDetail1.Consumable_order_minor__c = createIdSend.Id;
            conOrderDetail1.Lose_Flag__c = false;
            conOrderDetail1.Box_Piece__c = '盒';
            insert new Consumable_order_details2__c[]{conOrderDetail1};
            insert new List<Consumable_order_details2__c>{ conOrderDetail1 };
            hospitalprice__c hp1 = new hospitalprice__c();
            hp1.hospital__c = accountId;
            hp1.account__c = accountId;
            hp1.product__c = pro1.Id;
            insert new hospitalprice__c[]{hp1};
            insert new List<hospitalprice__c>{ hp1 };
            Integer size = Integer.valueOf(System.Label.orderdetLimitsize);
            String ESetId = createIdSend.Id;
@@ -1904,33 +2667,91 @@
            codi1.Prod = pro1;
            consumable.add(codi);
            System.Test.startTest();
            LexSummonsCreatController.save(createIdSend,'','','',pageRecordsLwc,accountId,createIdSend.Id,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend1,'','','',pageRecordsLwc,accountId,null,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(createIdSend,'','','',pageRecords1,accountId,null,consumable,agencyProType,userWorkLocation);
            LexSummonsCreatController.save(
                createIdSend,
                '',
                '',
                '',
                pageRecordsLwc,
                accountId,
                createIdSend.Id,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend1,
                '',
                '',
                '',
                pageRecordsLwc,
                accountId,
                null,
                consumable,
                agencyProType,
                userWorkLocation
            );
            LexSummonsCreatController.save(
                createIdSend,
                '',
                '',
                '',
                pageRecords1,
                accountId,
                null,
                consumable,
                agencyProType,
                userWorkLocation
            );
            System.Test.stopTest();
        }
    }
    static testMethod void testInnerClass(){
    static testMethod void testInnerClass() {
        Account accountItem1;
        Account accountItem2;
        User userTest;
        String rectCo = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
        String rectHp = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
        Profile prof = [SELECT Id FROM Profile WHERE Name ='901_经销商社区普通权限_2重验证(ET)'];
        accountItem1 = new Account(Name='Testaccount001',RecordTypeId = rectCo, AgentCode_Ext__c = '9999900');
        Profile prof = [SELECT Id FROM Profile WHERE Name = '901_经销商社区普通权限_2重验证(ET)'];
        accountItem1 = new Account(Name = 'Testaccount001', RecordTypeId = rectCo, AgentCode_Ext__c = '9999900');
        insert accountItem1;
        accountItem2 = new Account(Name='Testaccount002',RecordTypeId = rectHp, AgentCode_Ext__c = '9999999', ParentId = accountItem1.Id,Contract_Decide_Start_Date__c = Date.today(),ENG_Dealer__c = true,BillingCity = null);
        accountItem2 = new Account(
            Name = 'Testaccount002',
            RecordTypeId = rectHp,
            AgentCode_Ext__c = '9999999',
            ParentId = accountItem1.Id,
            Contract_Decide_Start_Date__c = Date.today(),
            ENG_Dealer__c = true,
            BillingCity = null
        );
        insert accountItem2;
        Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe', lastname='Plumber', accountId = accountItem1.Id);
        Contact core = new Contact(email = 'jplumber@salesforce.com', firstname = 'Joe', lastname = 'Plumber', accountId = accountItem1.Id);
        insert core;
        System.runAs(new user(ID = UserInfo.getUserID())) {
            userTest = New User(ContactId = core.id, Alias = 'newUser', Email='newuser@testorg.com', EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN', LocaleSidKey='zh_CN', ProfileId = prof.Id, TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com', UserPro_Type__c='ENG', Work_Location__c='北京');
            userTest = new User(
                ContactId = core.id,
                Alias = 'newUser',
                Email = 'newuser@testorg.com',
                EmailEncodingKey = 'UTF-8',
                LastName = 'TestUser',
                LanguageLocaleKey = 'zh_CN',
                LocaleSidKey = 'zh_CN',
                ProfileId = prof.Id,
                TimeZoneSidKey = 'Asia/Shanghai',
                UserName = 'testUser@testorg.com',
                UserPro_Type__c = 'ENG',
                Work_Location__c = '北京'
            );
            insert userTest;
        }
        System.runAs(userTest){
        System.runAs(userTest) {
            String userId = UserInfo.getUserId();
            User thisUserInfo = [SELECT accountid, UserPro_Type__c, ContactId, Contact.AccountId,Contact.Account.Name, Work_Location__c FROM User WHERE id =:userId];
            User thisUserInfo = [
                SELECT accountid, UserPro_Type__c, ContactId, Contact.AccountId, Contact.Account.Name, Work_Location__c
                FROM User
                WHERE id = :userId
            ];
            String accountId = thisUserInfo.accountid;
            String accountName = thisUserInfo.Contact.Account.Name;
            String agencyProType = thisUserInfo.UserPro_Type__c;
@@ -1940,10 +2761,29 @@
            if (String.isBlank(thisUserInfo.UserPro_Type__c)) {
                agencyProType = 'ET';
            }
           Product2 prod07 = new Product2(Name='Test07',ProductCode='Test07',Asset_Model_No__c = 'Test07', ProductCode_Ext__c = 'Test07',Category3__c = 'Test7',Category4__c = 'Test77',Category5__c = 'Test777',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false);
           insert new Product2[] {prod07};
            Product2__c pro1 = new Product2__c(Name='MH-155:白平衡帽',OT_CODE_Text__c='Test001',Product2__c = prod07.Id,Category3_text__c = 'test123', Category4_text__c = 'test123', Category5_text__c = 'test123');
         insert new Product2__c[] {pro1};
            Product2 prod07 = new Product2(
                Name = 'Test07',
                ProductCode = 'Test07',
                Asset_Model_No__c = 'Test07',
                ProductCode_Ext__c = 'Test07',
                Category3__c = 'Test7',
                Category4__c = 'Test77',
                Category5__c = 'Test777',
                SFDA_Status__c = '有効',
                Dealer_special_Object__c = true,
                Packing_list_manual__c = 1,
                Manual_Entry__c = false
            );
            insert new List<Product2>{ prod07 };
            Product2__c pro1 = new Product2__c(
                Name = 'MH-155:白平衡帽',
                OT_CODE_Text__c = 'Test001',
                Product2__c = prod07.Id,
                Category3_text__c = 'test123',
                Category4_text__c = 'test123',
                Category5_text__c = 'test123'
            );
            insert new List<Product2__c>{ pro1 };
            Consumable_order__c createIdSend = new Consumable_order__c();
            createIdSend.Name = 'testMing1';
            createIdSend.Order_status__c = '批准';
@@ -1986,8 +2826,8 @@
            createIdArrived.orderPattern__c = 'promotionorder';
            createIdArrived.Dealer_Info__c = accountItem1.Id;
            createIdArrived.Delivery_detail_count__c = 5;
            insert new Consumable_order__c[]{createIdSend,createIdSend3,createIdArrived};
            insert new List<Consumable_order__c>{ createIdSend, createIdSend3, createIdArrived };
            Consumable_orderdetails__c coc = new Consumable_orderdetails__c();
            coc.Name = 'Too001';
            coc.Dealer_Custom_Price__c = 999.00;
@@ -2013,7 +2853,7 @@
            coc1.Delivery_List_RMB__c = 999.00;
            coc1.Shipment_Count__c = 9999.00;
            coc1.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
            insert new Consumable_orderdetails__c[]{coc,coc1};
            insert new List<Consumable_orderdetails__c>{ coc, coc1 };
            Consumable_order_details2__c conOrderDetail1 = new Consumable_order_details2__c();
            conOrderDetail1.Name = 'OCM_01_001001';
@@ -2050,7 +2890,7 @@
            conOrderDetail2.Cancellation_Flag__c = false;
            conOrderDetail2.Box_Piece__c = '个';
            conOrderDetail2.Sterilization_limit__c = Date.Today();
            insert new Consumable_order_details2__c[]{conOrderDetail1,conOrderDetail2};
            insert new List<Consumable_order_details2__c>{ conOrderDetail1, conOrderDetail2 };
            List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecords = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
            LexSummonsCreatController.ConsumableorderdetailsInfoLwc c6 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
            c6.check = true;
@@ -2109,99 +2949,188 @@
            codi.boxorpiecein = null;
            codi.orderdetails1 = coc;
            codi.Prod = pro1;
            consumable.add(codi);
            consumable.add(codi);
            System.Test.startTest();
            LexSummonsCreatController.init(null,'Test',1,100,createIdArrived.Id);
            LexSummonsCreatController.init(null,'Test',1,100,null);
            LexSummonsCreatController.init(null,null,1,100,createIdArrived.Id);
            LexSummonsCreatController.init(null, 'Test', 1, 100, createIdArrived.Id);
            LexSummonsCreatController.init(null, 'Test', 1, 100, null);
            LexSummonsCreatController.init(null, null, 1, 100, createIdArrived.Id);
            LexSummonsCreatController.categoryAllload('Test7');
            LexSummonsCreatController.categoryload('Test7','Test77');
            LexSummonsCreatController.searchConsumableorderdetails('ET','Testaccount001','北京','ishos','Test07','Test7','Test77','Test777',true,pageRecords,consumable,'',1,1);
            LexSummonsCreatController.searchConsumableorderdetails('ET','Testaccount001','北京','nothos','Test07','Test7','Test77','Test777',true,pageRecords,consumable,'',1,1);
            LexSummonsCreatController.searchConsumableorderdetails('ET','Testaccount001','北京','ishos','Test07','Test7','Test77','Test777',true,pageRecords1,consumable,'',1,1);
            LexSummonsCreatController.searchConsumableorderdetails('ET','Testaccount001','北京','nothos','Test07','Test7','Test77','Test777',true,pageRecords1,consumable,'',1,1);
            LexSummonsCreatController.categoryload('Test7', 'Test77');
            LexSummonsCreatController.searchConsumableorderdetails(
                'ET',
                'Testaccount001',
                '北京',
                'ishos',
                'Test07',
                'Test7',
                'Test77',
                'Test777',
                true,
                pageRecords,
                consumable,
                '',
                1,
                1
            );
            LexSummonsCreatController.searchConsumableorderdetails(
                'ET',
                'Testaccount001',
                '北京',
                'nothos',
                'Test07',
                'Test7',
                'Test77',
                'Test777',
                true,
                pageRecords,
                consumable,
                '',
                1,
                1
            );
            LexSummonsCreatController.searchConsumableorderdetails(
                'ET',
                'Testaccount001',
                '北京',
                'ishos',
                'Test07',
                'Test7',
                'Test77',
                'Test777',
                true,
                pageRecords1,
                consumable,
                '',
                1,
                1
            );
            LexSummonsCreatController.searchConsumableorderdetails(
                'ET',
                'Testaccount001',
                '北京',
                'nothos',
                'Test07',
                'Test7',
                'Test77',
                'Test777',
                true,
                pageRecords1,
                consumable,
                '',
                1,
                1
            );
            List<LexSummonsCreatController.ConsumableorderdetailsInfo> cro = new List<LexSummonsCreatController.ConsumableorderdetailsInfo>();
            cro.sort();
            cro.sort();
            System.Test.stopTest();
        }
    }
    @isTest
    static void saveMethodTest1(){
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
      if (rectCo.size() == 0) {
         return;
      }
      Profile prof = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
        RecordType rectCoO = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
      Account myAccount2 = new Account(RecordTypeId = rectCoO.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
      Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id);
      insert new account[]{myAccount1,myAccount2};
    static void saveMethodTest1() {
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '販売店'];
        if (rectCo.size() == 0) {
            return;
        }
        Profile prof = [SELECT Id FROM Profile WHERE Name = '901_经销商社区普通权限_2重验证(ET)'];
        RecordType rectCoO = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        Account myAccount2 = new Account(RecordTypeId = rectCoO.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
        Account myAccount1 = new Account(name = 'Testaccount001', Dealer_discount__c = 30, RecordTypeId = rectCo[0].Id);
        insert new List<account>{ myAccount1, myAccount2 };
        hospitalprice__c hp1 = new hospitalprice__c();
        hp1.hospital__c = myAccount2.Id;
        hp1.account__c = myAccount1.Id;
        insert hp1;
      Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.id);
      insert core;
      user 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 = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com',UserPro_Type__c = 'ET',Work_Location__c='北京');
      System.runAs(new User(Id = UserInfo.getUserId())){
        Contact core = new Contact(email = 'jplumber@salesforce.com', firstname = 'Joe', lastname = 'Plumber', accountid = myAccount1.id);
        insert core;
        user 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 = prof.Id,
            TimeZoneSidKey = 'Asia/Shanghai',
            UserName = 'testUser@testorg.com',
            UserPro_Type__c = 'ET',
            Work_Location__c = '北京'
        );
        System.runAs(new User(Id = UserInfo.getUserId())) {
            insert MyUser_Test;
        }
      System.runAs(MyUser_Test){
            Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',JANCODE__c = '04953170200311',Dealer_special_Object__c = true,Manual_Entry__c = false);
         Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',JANCODE__c = '04953170200312',Dealer_special_Object__c = true,Manual_Entry__c = false);
         insert new Product2[] {prod01,prod02};
         Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='N3047730',Product2__c = prod01.Id);
         Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='N3047731',Product2__c = prod02.Id);
         insert new Product2__c[] {pro1, pro2};
            Consumable_order__c Order0 = new Consumable_order__c();
         Order0.Name = 'OCM_01_000';
         Order0.Order_status__c = '批准';
         Order0.Order_type__c = '订单';
         Order0.Dealer_Info__c = myAccount1.id;
         Order0.RecordTypeid = System.Label.RT_ConOrder_Delivery;
         Order0.Order_ProType__c = 'ET';
         insert Order0;
         Consumable_order__c Order1 = new Consumable_order__c();
         Order1.Name = 'OCM_01_001';
         Order1.Order_status__c = '批准';
         Order1.Order_type__c = '订单';
         Order1.Dealer_Info__c = myAccount1.id;
         Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
         Order1.Order_ProType__c = 'ET';
        System.runAs(MyUser_Test) {
            Product2 prod01 = new Product2(
                Name = 'Test01',
                ProductCode = 'Test01',
                Asset_Model_No__c = 'Test01',
                SFDA_Status__c = '有効',
                JANCODE__c = '04953170200311',
                Dealer_special_Object__c = true,
                Manual_Entry__c = false
            );
            Product2 prod02 = new Product2(
                Name = 'Test02',
                ProductCode = 'Test02',
                Asset_Model_No__c = 'Test02',
                SFDA_Status__c = '有効',
                JANCODE__c = '04953170200312',
                Dealer_special_Object__c = true,
                Manual_Entry__c = false
            );
            insert new List<Product2>{ prod01, prod02 };
            Product2__c pro1 = new Product2__c(Name = 'Pro001', OT_CODE_Text__c = 'N3047730', Product2__c = prod01.Id);
            Product2__c pro2 = new Product2__c(Name = 'Pro002', OT_CODE_Text__c = 'N3047731', Product2__c = prod02.Id);
            insert new List<Product2__c>{ pro1, pro2 };
            Consumable_order__c Order0 = new Consumable_order__c();
            Order0.Name = 'OCM_01_000';
            Order0.Order_status__c = '批准';
            Order0.Order_type__c = '订单';
            Order0.Dealer_Info__c = myAccount1.id;
            Order0.RecordTypeid = System.Label.RT_ConOrder_Delivery;
            Order0.Order_ProType__c = 'ET';
            insert Order0;
            Consumable_order__c Order1 = new Consumable_order__c();
            Order1.Name = 'OCM_01_001';
            Order1.Order_status__c = '批准';
            Order1.Order_type__c = '订单';
            Order1.Dealer_Info__c = myAccount1.id;
            Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
            Order1.Order_ProType__c = 'ET';
            Order1.OutPattern__c = true;
            Order1.Arrive_Order__c = Order0.Id;
         insert Order1;
         Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
         Orderdet.Name = 'OCM_01_00101';
         Orderdet.Consumable_order__c = Order1.Id;
         Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
         Orderdet.Consumable_Product__c = pro1.Id;
         Orderdet.Consumable_count__c = 4;
            insert Order1;
            Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
            Orderdet.Name = 'OCM_01_00101';
            Orderdet.Consumable_order__c = Order1.Id;
            Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
            Orderdet.Consumable_Product__c = pro1.Id;
            Orderdet.Consumable_count__c = 4;
            Orderdet.Shipment_Count__c = 10;
            Orderdet.isOutPattern__c = true;
            Orderdet.Delivery_List_RMB__c = 100;
            Orderdet.Box_Piece__c = '盒';
         insert Orderdet;
         Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
         Orderdet1.Name = 'OCM_01_001001';
         Orderdet1.Consumable_order_minor__c = Order1.Id;
         Orderdet1.Consumable_Product__c = pro1.Id;
         Orderdet1.Asset_Model_No__c = 'Test01';
         Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
         Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
         Orderdet1.Cancellation_Date__c = null;
         Orderdet1.TracingCode__c = 'BXJRF';
         Orderdet1.SerialLotNo__c = '5ZK';
            insert Orderdet;
            Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
            Orderdet1.Name = 'OCM_01_001001';
            Orderdet1.Consumable_order_minor__c = Order1.Id;
            Orderdet1.Consumable_Product__c = pro1.Id;
            Orderdet1.Asset_Model_No__c = 'Test01';
            Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
            Orderdet1.Cancellation_Date__c = null;
            Orderdet1.TracingCode__c = 'BXJRF';
            Orderdet1.SerialLotNo__c = '5ZK';
            Orderdet1.Arrive_date__c = Date.today();
            Orderdet1.exchangeOutPattern__c = true;
            Orderdet1.Consumable_ZS_order__c = Order1.Id;
            Orderdet1.Box_Piece__c = '盒';
         insert Orderdet1;
         System.Test.startTest();
            insert Orderdet1;
            System.Test.startTest();
            LexSummonsCreatController.init(Order1.Id, 'edit', 10, 1, '');
            List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pList = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
            LexSummonsCreatController.ConsumableorderdetailsInfoLwc p = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
@@ -2228,179 +3157,269 @@
            consumable.add(codi);
            LexSummonsCreatController.coc.SummonsForDirction__c = '直接销售给医院';
            LexSummonsCreatController.coc.Order_ForCustomerText__c = '消化科';
            LexSummonsCreatController.save(LexSummonsCreatController.coc, myAccount2.Id, myAccount2.Name, '', pList, myAccount1.Id, '', consumable, 'ET', '');
            LexSummonsCreatController.save(
                LexSummonsCreatController.coc,
                myAccount2.Id,
                myAccount2.Name,
                '',
                pList,
                myAccount1.Id,
                '',
                consumable,
                'ET',
                ''
            );
            Orderdet.Box_Piece__c = '个';
            LexSummonsCreatController.save(LexSummonsCreatController.coc, myAccount2.Id, myAccount2.Name, '', pList, myAccount1.Id, '', consumable, 'ET', '');
            LexSummonsCreatController.save(
                LexSummonsCreatController.coc,
                myAccount2.Id,
                myAccount2.Name,
                '',
                pList,
                myAccount1.Id,
                '',
                consumable,
                'ET',
                ''
            );
            p.Piecenumber = 20;
            LexSummonsCreatController.save(LexSummonsCreatController.coc, myAccount2.Id, myAccount2.Name, '', pList, myAccount1.Id, '', consumable, 'ET', '');
         System.Test.stopTest();
      }
            LexSummonsCreatController.save(
                LexSummonsCreatController.coc,
                myAccount2.Id,
                myAccount2.Name,
                '',
                pList,
                myAccount1.Id,
                '',
                consumable,
                'ET',
                ''
            );
            System.Test.stopTest();
        }
    }
    @isTest
    static void initMethodTest1(){
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
      if (rectCo.size() == 0) {
         return;
      }
      Profile prof = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
        RecordType rectCoO = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
      Account myAccount2 = new Account(RecordTypeId = rectCoO.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
      Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id);
      insert new account[]{myAccount1,myAccount2};
    static void initMethodTest1() {
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '販売店'];
        if (rectCo.size() == 0) {
            return;
        }
        Profile prof = [SELECT Id FROM Profile WHERE Name = '901_经销商社区普通权限_2重验证(ET)'];
        RecordType rectCoO = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        Account myAccount2 = new Account(RecordTypeId = rectCoO.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
        Account myAccount1 = new Account(name = 'Testaccount001', Dealer_discount__c = 30, RecordTypeId = rectCo[0].Id);
        insert new List<account>{ myAccount1, myAccount2 };
        hospitalprice__c hp1 = new hospitalprice__c();
        hp1.hospital__c = myAccount2.Id;
        hp1.account__c = myAccount1.Id;
        insert hp1;
      Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.id);
      insert core;
      user 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 = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com',UserPro_Type__c = 'ET',Work_Location__c='北京');
      System.runAs(new User(Id = UserInfo.getUserId())){
        Contact core = new Contact(email = 'jplumber@salesforce.com', firstname = 'Joe', lastname = 'Plumber', accountid = myAccount1.id);
        insert core;
        user 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 = prof.Id,
            TimeZoneSidKey = 'Asia/Shanghai',
            UserName = 'testUser@testorg.com',
            UserPro_Type__c = 'ET',
            Work_Location__c = '北京'
        );
        System.runAs(new User(Id = UserInfo.getUserId())) {
            insert MyUser_Test;
        }
      System.runAs(MyUser_Test){
            Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',JANCODE__c = '04953170200311',Dealer_special_Object__c = true,Manual_Entry__c = false);
         Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',JANCODE__c = '04953170200312',Dealer_special_Object__c = true,Manual_Entry__c = false);
         insert new Product2[] {prod01,prod02};
         Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='N3047730',Product2__c = prod01.Id);
         Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='N3047731',Product2__c = prod02.Id);
         insert new Product2__c[] {pro1, pro2};
            Consumable_order__c Order0 = new Consumable_order__c();
         Order0.Name = 'OCM_01_000';
         Order0.Order_status__c = '批准';
         Order0.Order_type__c = '订单';
         Order0.Dealer_Info__c = myAccount1.id;
         Order0.RecordTypeid = System.Label.RT_ConOrder_Delivery;
         Order0.Order_ProType__c = 'ET';
         insert Order0;
         Consumable_order__c Order1 = new Consumable_order__c();
         Order1.Name = 'OCM_01_001';
         Order1.Order_status__c = '批准';
         Order1.Order_type__c = '传票';
         Order1.Dealer_Info__c = myAccount1.id;
         Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
         Order1.Order_ProType__c = 'ET';
        System.runAs(MyUser_Test) {
            Product2 prod01 = new Product2(
                Name = 'Test01',
                ProductCode = 'Test01',
                Asset_Model_No__c = 'Test01',
                SFDA_Status__c = '有効',
                JANCODE__c = '04953170200311',
                Dealer_special_Object__c = true,
                Manual_Entry__c = false
            );
            Product2 prod02 = new Product2(
                Name = 'Test02',
                ProductCode = 'Test02',
                Asset_Model_No__c = 'Test02',
                SFDA_Status__c = '有効',
                JANCODE__c = '04953170200312',
                Dealer_special_Object__c = true,
                Manual_Entry__c = false
            );
            insert new List<Product2>{ prod01, prod02 };
            Product2__c pro1 = new Product2__c(Name = 'Pro001', OT_CODE_Text__c = 'N3047730', Product2__c = prod01.Id);
            Product2__c pro2 = new Product2__c(Name = 'Pro002', OT_CODE_Text__c = 'N3047731', Product2__c = prod02.Id);
            insert new List<Product2__c>{ pro1, pro2 };
            Consumable_order__c Order0 = new Consumable_order__c();
            Order0.Name = 'OCM_01_000';
            Order0.Order_status__c = '批准';
            Order0.Order_type__c = '订单';
            Order0.Dealer_Info__c = myAccount1.id;
            Order0.RecordTypeid = System.Label.RT_ConOrder_Delivery;
            Order0.Order_ProType__c = 'ET';
            insert Order0;
            Consumable_order__c Order1 = new Consumable_order__c();
            Order1.Name = 'OCM_01_001';
            Order1.Order_status__c = '批准';
            Order1.Order_type__c = '传票';
            Order1.Dealer_Info__c = myAccount1.id;
            Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
            Order1.Order_ProType__c = 'ET';
            Order1.OutPattern__c = true;
            Order1.Arrive_Order__c = Order0.Id;
            Order1.SummonsStatus_c__c = '已提交';
            Order1.SummonsForDirction__c = '直接销售给医院';
         insert Order1;
         Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
         Orderdet.Name = 'OCM_01_00101';
         Orderdet.Consumable_order__c = Order1.Id;
         Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
         Orderdet.Consumable_Product__c = pro1.Id;
         Orderdet.Consumable_count__c = 4;
            insert Order1;
            Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
            Orderdet.Name = 'OCM_01_00101';
            Orderdet.Consumable_order__c = Order1.Id;
            Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
            Orderdet.Consumable_Product__c = pro1.Id;
            Orderdet.Consumable_count__c = 4;
            Orderdet.Shipment_Count__c = 10;
            Orderdet.isOutPattern__c = true;
            Orderdet.Delivery_List_RMB__c = 100;
            Orderdet.Box_Piece__c = '盒';
         insert Orderdet;
         Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
         Orderdet1.Name = 'OCM_01_001001';
         Orderdet1.Consumable_order_minor__c = Order1.Id;
         Orderdet1.Consumable_Product__c = pro1.Id;
         Orderdet1.Asset_Model_No__c = 'Test01';
         Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
         Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
         Orderdet1.Cancellation_Date__c = null;
         Orderdet1.TracingCode__c = 'BXJRF';
         Orderdet1.SerialLotNo__c = '5ZK';
            insert Orderdet;
            Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
            Orderdet1.Name = 'OCM_01_001001';
            Orderdet1.Consumable_order_minor__c = Order1.Id;
            Orderdet1.Consumable_Product__c = pro1.Id;
            Orderdet1.Asset_Model_No__c = 'Test01';
            Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
            Orderdet1.Cancellation_Date__c = null;
            Orderdet1.TracingCode__c = 'BXJRF';
            Orderdet1.SerialLotNo__c = '5ZK';
            Orderdet1.Arrive_date__c = Date.today();
            Orderdet1.exchangeOutPattern__c = true;
            Orderdet1.Consumable_ZS_order__c = Order1.Id;
            Orderdet1.Box_Piece__c = '盒';
         insert Orderdet1;
         System.Test.startTest();
            insert Orderdet1;
            System.Test.startTest();
            LexSummonsCreatController.init(Order1.Id, 'edit', 10, 1, '');
         System.Test.stopTest();
      }
            System.Test.stopTest();
        }
    }
    @isTest
    static void initMethodTest2(){
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
      if (rectCo.size() == 0) {
         return;
      }
      Profile prof = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
        RecordType rectCoO = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
      Account myAccount2 = new Account(RecordTypeId = rectCoO.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
      Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id);
      insert new account[]{myAccount1,myAccount2};
    static void initMethodTest2() {
        List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '販売店'];
        if (rectCo.size() == 0) {
            return;
        }
        Profile prof = [SELECT Id FROM Profile WHERE Name = '901_经销商社区普通权限_2重验证(ET)'];
        RecordType rectCoO = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
        Account myAccount2 = new Account(RecordTypeId = rectCoO.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
        Account myAccount1 = new Account(name = 'Testaccount001', Dealer_discount__c = 30, RecordTypeId = rectCo[0].Id);
        insert new List<account>{ myAccount1, myAccount2 };
        hospitalprice__c hp1 = new hospitalprice__c();
        hp1.hospital__c = myAccount2.Id;
        hp1.account__c = myAccount1.Id;
        insert hp1;
      Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.id);
      insert core;
      user 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 = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com',UserPro_Type__c = 'ET');
      System.runAs(new User(Id = UserInfo.getUserId())){
        Contact core = new Contact(email = 'jplumber@salesforce.com', firstname = 'Joe', lastname = 'Plumber', accountid = myAccount1.id);
        insert core;
        user 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 = prof.Id,
            TimeZoneSidKey = 'Asia/Shanghai',
            UserName = 'testUser@testorg.com',
            UserPro_Type__c = 'ET'
        );
        System.runAs(new User(Id = UserInfo.getUserId())) {
            insert MyUser_Test;
        }
      System.runAs(MyUser_Test){
            Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',JANCODE__c = '04953170200311',Dealer_special_Object__c = true,Manual_Entry__c = false);
         Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',JANCODE__c = '04953170200312',Dealer_special_Object__c = true,Manual_Entry__c = false);
         insert new Product2[] {prod01,prod02};
         Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='N3047730',Product2__c = prod01.Id);
         Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='N3047731',Product2__c = prod02.Id);
         insert new Product2__c[] {pro1, pro2};
            Consumable_order__c Order0 = new Consumable_order__c();
         Order0.Name = 'OCM_01_000';
         Order0.Order_status__c = '批准';
         Order0.Order_type__c = '订单';
         Order0.Dealer_Info__c = myAccount1.id;
         Order0.RecordTypeid = System.Label.RT_ConOrder_Delivery;
         Order0.Order_ProType__c = 'ET';
         insert Order0;
         Consumable_order__c Order1 = new Consumable_order__c();
         Order1.Name = 'OCM_01_001';
         Order1.Order_status__c = '批准';
         Order1.Order_type__c = '订单';
         Order1.Dealer_Info__c = myAccount1.id;
         Order1.RecordTypeid = System.Label.RT_ConOrder_Arrive;
         Order1.Order_ProType__c = 'ET';
        System.runAs(MyUser_Test) {
            Product2 prod01 = new Product2(
                Name = 'Test01',
                ProductCode = 'Test01',
                Asset_Model_No__c = 'Test01',
                SFDA_Status__c = '有効',
                JANCODE__c = '04953170200311',
                Dealer_special_Object__c = true,
                Manual_Entry__c = false
            );
            Product2 prod02 = new Product2(
                Name = 'Test02',
                ProductCode = 'Test02',
                Asset_Model_No__c = 'Test02',
                SFDA_Status__c = '有効',
                JANCODE__c = '04953170200312',
                Dealer_special_Object__c = true,
                Manual_Entry__c = false
            );
            insert new List<Product2>{ prod01, prod02 };
            Product2__c pro1 = new Product2__c(Name = 'Pro001', OT_CODE_Text__c = 'N3047730', Product2__c = prod01.Id);
            Product2__c pro2 = new Product2__c(Name = 'Pro002', OT_CODE_Text__c = 'N3047731', Product2__c = prod02.Id);
            insert new List<Product2__c>{ pro1, pro2 };
            Consumable_order__c Order0 = new Consumable_order__c();
            Order0.Name = 'OCM_01_000';
            Order0.Order_status__c = '批准';
            Order0.Order_type__c = '订单';
            Order0.Dealer_Info__c = myAccount1.id;
            Order0.RecordTypeid = System.Label.RT_ConOrder_Delivery;
            Order0.Order_ProType__c = 'ET';
            insert Order0;
            Consumable_order__c Order1 = new Consumable_order__c();
            Order1.Name = 'OCM_01_001';
            Order1.Order_status__c = '批准';
            Order1.Order_type__c = '订单';
            Order1.Dealer_Info__c = myAccount1.id;
            Order1.RecordTypeid = System.Label.RT_ConOrder_Arrive;
            Order1.Order_ProType__c = 'ET';
            Order1.OutPattern__c = true;
            Order1.Arrive_Order__c = Order0.Id;
            Order1.SummonsStatus_c__c = '已提交';
            Order1.SummonsForDirction__c = '直接销售给医院';
         insert Order1;
         Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
         Orderdet.Name = 'OCM_01_00101';
         Orderdet.Consumable_order__c = Order0.Id;
         Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
         Orderdet.Consumable_Product__c = pro1.Id;
         Orderdet.Consumable_count__c = 4;
            insert Order1;
            Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
            Orderdet.Name = 'OCM_01_00101';
            Orderdet.Consumable_order__c = Order0.Id;
            Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
            Orderdet.Consumable_Product__c = pro1.Id;
            Orderdet.Consumable_count__c = 4;
            Orderdet.Shipment_Count__c = 10;
            Orderdet.isOutPattern__c = true;
            Orderdet.Delivery_List_RMB__c = 100;
            Orderdet.Box_Piece__c = '盒';
         insert Orderdet;
         Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
         Orderdet1.Name = 'OCM_01_001001';
         Orderdet1.Consumable_order_minor__c = Order1.Id;
         Orderdet1.Consumable_Product__c = pro1.Id;
         Orderdet1.Asset_Model_No__c = 'Test01';
         Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
         Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
         Orderdet1.Cancellation_Date__c = null;
         Orderdet1.TracingCode__c = 'BXJRF';
         Orderdet1.SerialLotNo__c = '5ZK';
            insert Orderdet;
            Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
            Orderdet1.Name = 'OCM_01_001001';
            Orderdet1.Consumable_order_minor__c = Order1.Id;
            Orderdet1.Consumable_Product__c = pro1.Id;
            Orderdet1.Asset_Model_No__c = 'Test01';
            Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
            Orderdet1.Cancellation_Date__c = null;
            Orderdet1.TracingCode__c = 'BXJRF';
            Orderdet1.SerialLotNo__c = '5ZK';
            Orderdet1.Arrive_date__c = Date.today();
            Orderdet1.exchangeOutPattern__c = true;
            Orderdet1.Consumable_ZS_order__c = Order1.Id;
            Orderdet1.Box_Piece__c = '盒';
            Orderdet1.Sterilization_limit__c= Date.today().addDays(2);
         insert Orderdet1;
         System.Test.startTest();
            Orderdet1.Sterilization_limit__c = Date.today().addDays(2);
            insert Orderdet1;
            System.Test.startTest();
            LexSummonsCreatController.init('', 'edit', 10, 1, Order1.Id);
         System.Test.stopTest();
      }
            System.Test.stopTest();
        }
    }
}
}