@isTest
private class LexSummonsCreatControllerTest {
  @isTest
  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'
    );
    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
    );
    insert accountItem2;
    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 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 = '北京'
      );
      insert userTest;
    }
    //发货
    Consumable_order__c consOrder = new Consumable_order__c();
    consOrder.Name = 'test01';
    consOrder.Order_status__c = '批准';
    consOrder.Deliver_date__c = Date.today();
    consOrder.RecordTypeid = System.Label.RT_ConOrder_Delivery;
    consOrder.Order_type__c = '订单';
    consOrder.Order_ProType__c = 'ENG';
    consOrder.Dealer_Info__c = accountItem1.Id;
    consOrder.Delivery_detail_count__c = 5;
    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
      )
    );
    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
    ]) {
      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'
      )
    );
    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) {
      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
      ];
      String accountId = thisUserInfo.accountid;
      String accountName = thisUserInfo.Contact.Account.Name;
      String agencyProType = thisUserInfo.UserPro_Type__c;
      String userWorkLocation = thisUserInfo.Work_Location__c;
      thisUserInfo.UserPro_Type__c = '';
      update thisUserInfo;
      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 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 = '批准';
      createIdSend.Deliver_date__c = Date.today();
      createIdSend.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      createIdSend.Order_type__c = '订单';
      createIdSend.Order_ProType__c = 'ENG';
      createIdSend.SummonsForDirction__c = '互相调货';
      createIdSend.Order_ForDealerText__c = 'Testaccount003';
      createIdSend.Order_ForCustomerText__c = 'Test000';
      createIdSend.SummonsStatus_c__c = '批准';
      createIdSend.Dealer_Info__c = accountItem1.Id;
      createIdSend.Delivery_detail_count__c = 5;

      Consumable_order__c createIdSend1 = new Consumable_order__c();
      createIdSend1.Name = 'testMing2';
      createIdSend1.Order_status__c = '批准';
      createIdSend1.Deliver_date__c = Date.today();
      createIdSend1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      createIdSend1.Order_type__c = '订单';
      createIdSend1.Order_ProType__c = 'ENG';
      createIdSend1.SummonsForDirction__c = '直接销售给医院';
      createIdSend1.Order_ForCustomerText__c = '';
      createIdSend1.Order_ForDealerText__c = 'Testaccount003';
      createIdSend1.SummonsStatus_c__c = '批准';
      createIdSend1.Dealer_Info__c = accountItem1.Id;
      createIdSend1.Delivery_detail_count__c = 5;

      Consumable_order__c createIdSend2 = new Consumable_order__c();
      createIdSend2.Name = 'testMing2';
      createIdSend2.Order_status__c = '批准';
      createIdSend2.Deliver_date__c = Date.today();
      createIdSend2.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      createIdSend2.Order_type__c = '订单';
      createIdSend2.Order_ProType__c = 'ENG';
      createIdSend2.SummonsForDirction__c = '';
      createIdSend2.Order_ForCustomerText__c = '';
      createIdSend2.Order_ForDealerText__c = 'Testaccount003';
      createIdSend2.SummonsStatus_c__c = '批准';
      createIdSend2.Dealer_Info__c = accountItem1.Id;
      createIdSend2.Delivery_detail_count__c = 5;

      Consumable_order__c createIdSend3 = new Consumable_order__c();
      createIdSend3.Name = 'testMing123456';
      createIdSend3.Order_status__c = '批准';
      createIdSend3.Deliver_date__c = Date.today();
      createIdSend3.Arrive_Order__c = createIdSend.Id;
      createIdSend3.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      createIdSend3.Order_type__c = '订单';
      createIdSend3.Order_ProType__c = 'ENG';
      createIdSend3.SummonsForDirction__c = '互相调货';
      createIdSend3.Order_ForDealerText__c = '';
      createIdSend3.Order_ForCustomerText__c = 'Test001';
      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 = '批准';
      createIdSend4.Deliver_date__c = Date.today();
      createIdSend4.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      createIdSend4.Order_type__c = '订单';
      createIdSend4.Order_ProType__c = 'ENG';
      createIdSend4.SummonsForDirction__c = '医院试用';
      createIdSend4.Order_ForDealerText__c = '';
      createIdSend4.Order_ForCustomerText__c = 'Test000';
      createIdSend4.SummonsStatus_c__c = '批准';
      createIdSend4.Dealer_Info__c = accountItem1.Id;
      createIdSend4.Delivery_detail_count__c = 5;

      Consumable_order__c createIdSend5 = new Consumable_order__c();
      createIdSend5.Name = 'testMing1111111';
      createIdSend5.Order_status__c = '批准';
      createIdSend5.Deliver_date__c = Date.today();
      createIdSend5.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      createIdSend5.Order_type__c = '订单';
      createIdSend5.Order_ProType__c = 'ENG';
      createIdSend5.SummonsForDirction__c = '销售给二级经销商';
      createIdSend5.Order_ForDealerText__c = '';
      createIdSend5.Order_ForCustomerText__c = '';
      createIdSend5.SummonsStatus_c__c = '批准';
      createIdSend5.Dealer_Info__c = accountItem1.Id;
      createIdSend5.Delivery_detail_count__c = 5;

      Consumable_order__c createIdSend6 = new Consumable_order__c();
      createIdSend6.Name = 'testMing222222';
      createIdSend6.Order_status__c = '批准';
      createIdSend6.Deliver_date__c = Date.today();
      createIdSend6.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      createIdSend6.Order_type__c = '订单';
      createIdSend6.Order_ProType__c = 'ENG';
      createIdSend6.SummonsForDirction__c = '销售给二级经销商';
      createIdSend6.Order_ForDealerText__c = '';
      createIdSend6.Order_ForCustomerText__c = '';
      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 = '批准';
      createIdSend7.Deliver_date__c = Date.today();
      createIdSend7.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      createIdSend7.Order_type__c = '订单';
      createIdSend7.Order_ProType__c = 'ENG';
      createIdSend7.SummonsForDirction__c = '互相调货';
      createIdSend7.Order_ForDealerText__c = '';
      createIdSend7.Order_ForCustomerText__c = '';
      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 = '批准';
      createIdSend8.Deliver_date__c = Date.today();
      createIdSend8.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      createIdSend8.Order_type__c = '订单';
      createIdSend8.Order_ProType__c = 'ENG';
      createIdSend8.SummonsForDirction__c = '测试001';
      createIdSend8.Order_ForDealerText__c = '';
      createIdSend8.Order_ForCustomerText__c = '';
      createIdSend8.SummonsStatus_c__c = '';
      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.Order_type__c = '发票';
      createIdSend9.RecordTypeid = System.Label.RT_ConOrder_Invoice;
      createIdSend9.Order_status__c = '草案中';
      createIdSend9.Invoice_Date__c = Date.Today();
      createIdSend9.Order_ProType__c = 'ENG';
      createIdSend9.SummonsForDirction__c = '直接销售给医院';

      Consumable_order__c createIdSend10 = new Consumable_order__c();
      createIdSend10.Name = 'OCMtest';
      createIdSend10.Order_status__c = '批准';
      createIdSend10.Order_type__c = '到货';
      createIdSend10.Dealer_Info__c = accountItem1.Id;
      createIdSend10.RecordTypeid = System.Label.RT_ConOrder_Arrive;
      createIdSend10.Order_ProType__c = 'ET';

      Consumable_order__c createIdSend11 = new Consumable_order__c();
      createIdSend11.Name = 'OCM_01_002';
      createIdSend11.Order_status__c = '批准';
      createIdSend11.Order_type__c = '传票';
      createIdSend11.Arrive_Order__c = createIdSend9.Id;
      createIdSend11.Dealer_Info__c = accountItem1.Id;
      createIdSend11.SummonsForDirction__c = '直接销售给医院';
      createIdSend11.RecordTypeid = System.Label.RT_ConOrder_Order;
      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.Arrive_Order__c = createIdSend9.Id;
      testList1.SummonsForDirction__c = '直接销售给医院';
      testList1.Order_status__c = '草案中';
      testList1.Order_type__c = '传票';
      testList1.Dealer_info__c = accountItem1.Id;
      testList1.ConInvoice_Code__c = createIdSend9.id;

      //到货
      Consumable_order__c createIdArrived = new Consumable_order__c();
      createIdArrived.Name = 'testMing2';
      createIdArrived.Order_status__c = '批准';
      createIdArrived.Deliver_date__c = Date.today();
      createIdArrived.RecordTypeid = System.Label.RT_ConOrder_Arrive;
      createIdArrived.Order_type__c = '订单';
      createIdArrived.Order_ProType__c = 'ET';
      createIdArrived.orderPattern__c = 'promotionorder';
      createIdArrived.Dealer_Info__c = accountItem1.Id;
      createIdArrived.Delivery_detail_count__c = 5;
      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 List<Consumable_order_LinkTable__c>{ order_LinkTable1 };

      Consumable_orderdetails__c coc = new Consumable_orderdetails__c();
      coc.Name = 'Too001';
      coc.Dealer_Custom_Price__c = 999.00;
      coc.Consumable_count__c = 3;
      coc.Consumable_product__c = pro1.Id;
      coc.Box_Piece__c = '盒';
      coc.isOutPattern__c = true;
      coc.Consumable_order__c = createIdSend.Id;
      coc.Unitprice_To_agency__c = 999.00;
      coc.Delivery_List_RMB__c = 999.00;
      coc.Shipment_Count__c = null;
      coc.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;

      Consumable_orderdetails__c coc1 = new Consumable_orderdetails__c();
      coc1.Name = 'Too001';
      coc1.Dealer_Custom_Price__c = 999.00;
      coc1.Consumable_count__c = 3;
      coc1.Consumable_product__c = pro1.Id;
      coc1.Box_Piece__c = '盒';
      coc1.isOutPattern__c = true;
      coc1.Consumable_order__c = createIdSend3.Id;
      coc1.Unitprice_To_agency__c = 999.00;
      coc1.Delivery_List_RMB__c = 999.00;
      coc1.Shipment_Count__c = 9999.00;
      coc1.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;

      Consumable_orderdetails__c coc2 = new Consumable_orderdetails__c();
      coc2.Name = 'Too001';
      coc2.Dealer_Custom_Price__c = 999.00;
      coc2.Consumable_count__c = 3;
      coc2.Consumable_product__c = pro1.Id;
      coc2.Box_Piece__c = '盒';
      coc2.isOutPattern__c = true;
      coc2.Consumable_order__c = createIdSend3.Id;
      coc2.Unitprice_To_agency__c = 999.00;
      coc2.Delivery_List_RMB__c = -999.00;
      coc2.Shipment_Count__c = 9999.00;
      coc2.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
      insert new List<Consumable_orderdetails__c>{ coc, coc1, coc2 };

      Consumable_order_details2__c conOrderDetail1 = new Consumable_order_details2__c();
      conOrderDetail1.Name = 'OCM_01_001001';
      conOrderDetail1.Consumable_ZS_order__c = createIdArrived.Id;
      conOrderDetail1.Consumable_Product__c = pro1.Id;
      conOrderDetail1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
      conOrderDetail1.Bar_Code__c = '11111';
      conOrderDetail1.Arrive_date__c = Date.today().addDays(1);
      conOrderDetail1.Send_Date__c = null;
      conOrderDetail1.Used_date__c = null;
      conOrderDetail1.Return_date__c = null;
      conOrderDetail1.Consumable_order_minor__c = createIdArrived.Id;
      conOrderDetail1.Lose_Flag__c = false;
      conOrderDetail1.exchangeOutPattern__c = false;
      conOrderDetail1.Cancellation_Flag__c = false;
      conOrderDetail1.Box_Piece__c = '盒';
      conOrderDetail1.Sterilization_limit__c = Date.Today();
      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 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 List<Dealer_elationship__c>{
        dealerelationship,
        dealerelationship1
      };

      LexSummonsCreatController.ConsumableorderdetailsInfo c0 = new LexSummonsCreatController.ConsumableorderdetailsInfo();
      c0.packinglist = 0;
      c0.approbation_No = null;
      c0.expiration_Date = Date.Today();
      c0.boxorpiecein = null;
      c0.hospitalSpecialOffer = true;
      LexSummonsCreatController.ConsumableorderdetailsInfo c1 = new LexSummonsCreatController.ConsumableorderdetailsInfo(
        coc
      );
      c1.check = true;
      c1.oldCheck = true;
      c1.orderdetails1 = coc;
      c1.orderdetails2 = null;
      c1.Prod = coc.Consumable_Product__r;
      c1.oldConsumableCount = coc.Shipment_Count__c;
      c1.canSelect = true;
      c1.allnumber = 0.00;
      c1.Boxnumber = 0.00;
      c1.Piecenumber = 0.00;
      c1.BoxPiece = coc.Box_Piece__c;
      c1.hospitalSpecialOffer = true;
      c1.hosPro = false;
      List<SelectOption> boxorpiece = new List<SelectOption>();
      boxorpiece.add(new SelectOption('盒', '盒'));
      boxorpiece.add(new SelectOption('个', '个'));
      Map<String, String> boxorpieceMap = new Map<String, String>();
      boxorpieceMap.put('盒', '盒');
      boxorpieceMap.put('个', '个');
      LexSummonsCreatController.ConsumableorderdetailsInfo coder = new LexSummonsCreatController.ConsumableorderdetailsInfo(
        conOrderDetail1
      );
      coder.check = true;
      coder.oldCheck = true;
      coder.hospitalSpecialOffer = true;
      coder.orderdetails1 = null;
      coder.orderdetails2 = conOrderDetail1;
      coder.Prod = conOrderDetail1.Consumable_Product__r;
      coder.canSelect = true;
      coder.allnumber = 0;
      coder.Boxnumber = 0;
      coder.Piecenumber = 0;
      coder.hosPro = false;
      LexSummonsCreatController.ConsumableorderdetailsInfo c2 = new LexSummonsCreatController.ConsumableorderdetailsInfo(
        pro1
      );
      c2.sortBy = true;
      c2.Boxnumber = 20;
      c1.compareTo(c2);
      c1.Boxnumber = 20;
      c2.Boxnumber = 10;
      c1.compareTo(c2);
      c1.Boxnumber = 10;
      c2.Boxnumber = 20;
      c2.compareTo(c1);
      c1.Boxnumber = 20;
      c2.Boxnumber = 10;
      c2.compareTo(c1);
      LexSummonsCreatController.ConsumableorderdetailsInfo c3 = new LexSummonsCreatController.ConsumableorderdetailsInfo(
        pro1
      );
      c3.sortBy = false;
      c3.Boxnumber = 10;
      c1.compareTo(c3);
      c1.Boxnumber = 20;
      c3.Boxnumber = 10;
      c1.compareTo(c3);
      c3.Boxnumber = 10;
      c1.Boxnumber = 20;
      c3.compareTo(c1);
      c3.Boxnumber = 20;
      c3.Boxnumber = 10;
      c1.compareTo(c1);
      LexSummonsCreatController.ConsumableorderdetailsInfoLwc c4 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
      c4.check = true;
      c4.oldCheck = true;
      c4.orderdetails1 = null;
      c4.orderdetails2 = null;
      c4.Prod = null;
      c4.Boxnumber = 0.00;
      c4.Piecenumber = 0.00;
      c4.allnumber = 0.00;
      c4.oldConsumableCount = 0.00;
      c4.canSelect = true;
      c4.sortBy = true;
      c4.packinglist = 1;
      c4.approbation_No = null;
      c4.expiration_Date = Date.Today();
      c4.boxorpiecein = null;
      c4.boxorpiece = null;
      c4.boxorpieceMap = null;
      c4.concc = null;
      c4.BoxPiece = null;
      c4.hospitalSpecialOffer = true;
      c4.hosPro = true;
      c4.unitOptions = null;
      c4.unitValue = null;
      c4.shipmentNumber = 1;
      c4.shippingUnitPrice = 0.00;
      c4.recordId = null;
      c4.Id = null;
      c4.Name = null;
      c4.Category3 = null;
      c4.Category4 = null;
      c4.Category5 = null;
      List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecordsLwcLwc = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
      LexSummonsCreatController.ConsumableorderdetailsInfoLwc c5 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
      c5.check = true;
      c5.orderdetails1 = coc;
      c5.hospitalSpecialOffer = true;
      c5.allnumber = 1999.00;
      pageRecordsLwcLwc.add(c5);
      List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecords = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
      LexSummonsCreatController.ConsumableorderdetailsInfoLwc c6 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
      c6.check = true;
      c6.oldCheck = true;
      c6.hospitalSpecialOffer = true;
      c6.orderdetails1 = coc1;
      c6.orderdetails2 = conOrderDetail1;
      c6.Prod = pro1;
      c6.Boxnumber = 0.00;
      c6.Piecenumber = 0.00;
      c6.allnumber = 1999.00;
      c6.oldConsumableCount = 1999.00;
      c6.canSelect = true;
      c6.sortBy = true;
      c6.packinglist = 1;
      c6.approbation_No = '';
      c6.expiration_Date = Date.Today();
      c6.boxorpiecein = '';
      c6.boxorpiece = null;
      c6.boxorpieceMap = null;
      c6.concc = null;
      c6.BoxPiece = null;
      c6.hosPro = true;
      pageRecords.add(c6);
      List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecordsLwc = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
      LexSummonsCreatController.ConsumableorderdetailsInfoLwc c7 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
      c7.check = true;
      c7.oldCheck = true;
      c7.hospitalSpecialOffer = true;
      c7.orderdetails1 = coc2;
      c7.orderdetails2 = conOrderDetail1;
      c7.Prod = pro1;
      c7.Boxnumber = 0.00;
      c7.Piecenumber = 0.00;
      c7.allnumber = 1999.00;
      c7.oldConsumableCount = 1999.00;
      c7.canSelect = true;
      c7.sortBy = true;
      c7.packinglist = 1;
      c7.approbation_No = '';
      c7.expiration_Date = Date.Today();
      c7.boxorpiecein = '';
      c7.boxorpiece = null;
      c7.boxorpieceMap = null;
      c7.concc = null;
      c7.BoxPiece = null;
      c7.hosPro = true;
      pageRecordsLwc.add(c7);

      List<LexSummonsCreatController.ConsumableorderdetailsInfo> consumable = new List<LexSummonsCreatController.ConsumableorderdetailsInfo>();
      LexSummonsCreatController.ConsumableorderdetailsInfo codi = new LexSummonsCreatController.ConsumableorderdetailsInfo();
      codi.check = true;
      codi.hospitalSpecialOffer = true;
      codi.packinglist = 0;
      codi.approbation_No = null;
      codi.expiration_Date = Date.Today();
      codi.boxorpiecein = null;
      codi.orderdetails1 = coc;
      codi.Prod = pro1;
      consumable.add(codi);
      List<SelectOption> categoryOptionList = new List<SelectOption>();
      System.Test.startTest();
      Integer size = Integer.valueOf(System.Label.orderdetLimitsize);
      String ESetId = null;
      String statusEdit = null;
      String arrive = null;
      String alertMessage = null;

      String category1 = '3400PK:PK针 5mm×33cm';
      String Category3 = '腹腔镜手术';
      String Category4 = 'PK';
      String Category5 = 'G400';
      LexSummonsCreatController.category1 = category1;
      LexSummonsCreatController.Category3 = Category3;
      LexSummonsCreatController.Category4 = Category4;
      LexSummonsCreatController.Category5 = Category5;
      LexSummonsCreatController.statusEdit = statusEdit;
      LexSummonsCreatController.alertMessage = alertMessage;
      LexSummonsCreatController.zaikuId = new List<String>();
      LexSummonsCreatController.categoryOptionMap = new Map<String, String>();
      LexSummonsCreatController.category4OptionMap = new Map<String, String>();
      LexSummonsCreatController.category5OptionMap = new Map<String, String>();
      LexSummonsCreatController.orderpieceorboxMap = new Map<String, String>();
      LexSummonsCreatController.orderagencypriceMap = new Map<String, Decimal>();
      LexSummonsCreatController.orderpriceMap = new Map<String, Decimal>();
      LexSummonsCreatController.orderdetCountMap = new Map<String, Decimal>();
      LexSummonsCreatController.hasSpecialHos = false;
      LexSummonsCreatController.outOutPattern = null;
      LexSummonsCreatController.provinceOptsMap = new Map<String, String>();
      LexSummonsCreatController.categoryOptionList = new List<SelectOption>();
      LexSummonsCreatController.category4OptionList = new List<SelectOption>();
      LexSummonsCreatController.category5OptionList = new List<SelectOption>();
      LexSummonsCreatController.outOutPatternOptionList = new List<SelectOption>();
      LexSummonsCreatController.orderdetails = new List<Consumable_orderdetails__c>();
      LexSummonsCreatController.consumableorderdetailsRecords = new List<LexSummonsCreatController.ConsumableorderdetailsInfo>();
      LexSummonsCreatController.consumableorderdetailsRecordserror = new List<LexSummonsCreatController.ConsumableorderdetailsInfo>();
      List<SelectOption> cityOpts1 = new List<SelectOption>();
      cityOpts1.add(new SelectOption('', '--无--'));
      cityOpts1.add(new SelectOption('ishos', '医院特价产品'));
      cityOpts1.add(new SelectOption('nothos', '非医院特价产品'));
      Map<String, String> optionMap = new Map<String, String>();
      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.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.checkOutPattern();
      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.DelConsumable(createIdSend.Id);
      System.Test.stopTest();
    }
  }

  @isTest
  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'
    );
    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
    );
    insert accountItem2;
    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 = '北京'
      );
      insert 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
      ];
      String accountId = thisUserInfo.accountid;
      String accountName = thisUserInfo.Contact.Account.Name;
      String agencyProType = thisUserInfo.UserPro_Type__c;
      String userWorkLocation = thisUserInfo.Work_Location__c;
      thisUserInfo.UserPro_Type__c = '';
      update thisUserInfo;
      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 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 = '批准';
      createIdSend.Deliver_date__c = Date.today();
      createIdSend.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      createIdSend.Order_type__c = '订单';
      createIdSend.Order_ProType__c = 'ENG';
      createIdSend.SummonsForDirction__c = '测试0001';
      createIdSend.Order_ForDealerText__c = 'Testaccount003';
      createIdSend.Order_ForCustomerText__c = 'Test000';
      createIdSend.SummonsStatus_c__c = '批准';
      createIdSend.Dealer_Info__c = accountItem1.Id;
      createIdSend.Delivery_detail_count__c = 5;

      Consumable_order__c createIdSend1 = new Consumable_order__c();
      createIdSend1.Name = 'testMing1';
      createIdSend1.Order_status__c = '批准';
      createIdSend1.Deliver_date__c = Date.today();
      createIdSend1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      createIdSend1.Order_type__c = '订单';
      createIdSend1.Order_ProType__c = 'ENG';
      createIdSend1.SummonsForDirction__c = '销售给二级经销商';
      createIdSend1.Order_ForDealerText__c = 'Testaccount003';
      createIdSend1.Order_ForCustomerText__c = 'Test000';
      createIdSend1.SummonsStatus_c__c = '价格未定';
      createIdSend1.Dealer_Info__c = accountItem1.Id;
      createIdSend1.Delivery_detail_count__c = 5;
      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;
      coc.Consumable_count__c = 3;
      coc.Consumable_product__c = pro1.Id;
      coc.Box_Piece__c = '盒';
      coc.isOutPattern__c = true;
      coc.Consumable_order__c = createIdSend.Id;
      coc.Unitprice_To_agency__c = 999.00;
      coc.Delivery_List_RMB__c = -999.00;
      coc.Shipment_Count__c = 9999.00;
      coc.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;

      Consumable_orderdetails__c coc1 = new Consumable_orderdetails__c();
      coc1.Name = 'Too001';
      coc1.Dealer_Custom_Price__c = 999.00;
      coc1.Consumable_count__c = 3;
      coc1.Consumable_product__c = pro1.Id;
      coc1.Box_Piece__c = '盒';
      coc1.isOutPattern__c = true;
      coc1.Consumable_order__c = createIdSend.Id;
      coc1.Unitprice_To_agency__c = 999.00;
      coc1.Delivery_List_RMB__c = null;
      coc1.Shipment_Count__c = 9999.00;
      coc1.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;

      Consumable_orderdetails__c coc2 = new Consumable_orderdetails__c();
      coc2.Name = 'Too001';
      coc2.Dealer_Custom_Price__c = 999.00;
      coc2.Consumable_count__c = 3;
      coc2.Consumable_product__c = pro1.Id;
      coc2.Box_Piece__c = '';
      coc2.isOutPattern__c = true;
      coc2.Consumable_order__c = createIdSend.Id;
      coc2.Unitprice_To_agency__c = 999.00;
      coc2.Delivery_List_RMB__c = 999.00;
      coc2.Shipment_Count__c = 9999.00;
      coc2.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;

      Consumable_orderdetails__c coc3 = new Consumable_orderdetails__c();
      coc3.Name = 'Too001';
      coc3.Dealer_Custom_Price__c = 999.00;
      coc3.Consumable_count__c = 3;
      coc3.Consumable_product__c = pro1.Id;
      coc3.Box_Piece__c = '盒';
      coc3.isOutPattern__c = true;
      coc3.Consumable_order__c = createIdSend1.Id;
      coc3.Unitprice_To_agency__c = 999.00;
      coc3.Delivery_List_RMB__c = 100.00;
      coc3.Shipment_Count__c = 9999.00;
      coc3.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
      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';
      conOrderDetail1.Consumable_ZS_order__c = createIdSend.Id;
      conOrderDetail1.Consumable_Product__c = pro1.Id;
      conOrderDetail1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
      conOrderDetail1.Bar_Code__c = '11111';
      conOrderDetail1.Arrive_date__c = Date.today().addDays(1);
      conOrderDetail1.Send_Date__c = null;
      conOrderDetail1.Used_date__c = null;
      conOrderDetail1.Return_date__c = null;
      conOrderDetail1.Consumable_order_minor__c = createIdSend.Id;
      conOrderDetail1.Lose_Flag__c = false;
      conOrderDetail1.Cancellation_Flag__c = false;
      conOrderDetail1.Box_Piece__c = '盒';
      conOrderDetail1.Sterilization_limit__c = Date.Today();
      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;
      c0.oldCheck = true;
      c0.hospitalSpecialOffer = true;
      c0.orderdetails1 = coc;
      c0.orderdetails2 = conOrderDetail1;
      c0.Prod = pro1;
      c0.Boxnumber = 0.00;
      c0.Piecenumber = 0.00;
      c0.allnumber = 1999.00;
      c0.oldConsumableCount = 1999.00;
      c0.canSelect = true;
      c0.sortBy = true;
      c0.packinglist = 1;
      c0.approbation_No = '';
      c0.expiration_Date = Date.Today();
      c0.boxorpiecein = '';
      c0.boxorpiece = null;
      c0.boxorpieceMap = null;
      c0.concc = null;
      c0.BoxPiece = null;
      c0.hosPro = true;
      pageRecords.add(c0);
      List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecords1 = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
      LexSummonsCreatController.ConsumableorderdetailsInfoLwc c1 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
      c1.check = true;
      c1.oldCheck = false;
      c1.hospitalSpecialOffer = true;
      c1.orderdetails1 = coc1;
      c1.orderdetails2 = conOrderDetail1;
      c1.Prod = pro1;
      c1.Boxnumber = 0.00;
      c1.Piecenumber = 0.00;
      c1.allnumber = 1999.00;
      c1.oldConsumableCount = 1999.00;
      c1.canSelect = true;
      c1.sortBy = true;
      c1.packinglist = 1;
      c1.approbation_No = '';
      c1.expiration_Date = Date.Today();
      c1.boxorpiecein = '';
      c1.boxorpiece = null;
      c1.boxorpieceMap = null;
      c1.concc = null;
      c1.BoxPiece = null;
      c1.hosPro = true;
      pageRecords1.add(c1);
      List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecords2 = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
      LexSummonsCreatController.ConsumableorderdetailsInfoLwc c2 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
      c2.check = true;
      c2.oldCheck = false;
      c2.hospitalSpecialOffer = true;
      c2.orderdetails1 = coc2;
      c2.orderdetails2 = conOrderDetail1;
      c2.Prod = pro1;
      c2.Boxnumber = 0.00;
      c2.Piecenumber = 0.00;
      c2.allnumber = 1999.00;
      c2.oldConsumableCount = 1999.00;
      c2.canSelect = true;
      c2.sortBy = true;
      c2.packinglist = 1;
      c2.approbation_No = '';
      c2.expiration_Date = Date.Today();
      c2.boxorpiecein = '';
      c2.boxorpiece = null;
      c2.boxorpieceMap = null;
      c2.concc = null;
      c2.BoxPiece = null;
      c2.hosPro = true;
      pageRecords2.add(c2);
      List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecords3 = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
      LexSummonsCreatController.ConsumableorderdetailsInfoLwc c3 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
      c3.check = true;
      c3.oldCheck = false;
      c3.hospitalSpecialOffer = true;
      c3.orderdetails1 = coc3;
      c3.orderdetails2 = conOrderDetail1;
      c3.Prod = pro1;
      c3.Boxnumber = 0.00;
      c3.Piecenumber = 0.00;
      c3.allnumber = 1999.00;
      c3.oldConsumableCount = 1999.00;
      c3.canSelect = true;
      c3.sortBy = true;
      c3.packinglist = 1;
      c3.approbation_No = '';
      c3.expiration_Date = Date.Today();
      c3.boxorpiecein = '';
      c3.boxorpiece = null;
      c3.boxorpieceMap = null;
      c3.concc = null;
      c3.BoxPiece = null;
      c3.hosPro = true;
      pageRecords3.add(c3);
      List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecords0 = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
      LexSummonsCreatController.ConsumableorderdetailsInfoLwc c001 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
      c001.check = true;
      c001.oldCheck = true;
      c001.hospitalSpecialOffer = true;
      c001.orderdetails1 = coc3;
      c001.orderdetails2 = conOrderDetail1;
      c001.Prod = pro1;
      c001.Boxnumber = 0.00;
      c001.Piecenumber = 0.00;
      c001.allnumber = 1999.00;
      c001.oldConsumableCount = 1999.00;
      c001.canSelect = true;
      c001.sortBy = true;
      c001.packinglist = 1;
      c001.approbation_No = '';
      c001.expiration_Date = Date.Today();
      c001.boxorpiecein = '';
      c001.boxorpiece = null;
      c001.boxorpieceMap = null;
      c001.concc = null;
      c001.BoxPiece = null;
      c001.hosPro = true;
      pageRecords0.add(c001);
      List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecords4 = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
      LexSummonsCreatController.ConsumableorderdetailsInfoLwc c4 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
      c4.check = true;
      c4.oldCheck = true;
      c4.hospitalSpecialOffer = true;
      c4.orderdetails1 = coc2;
      c4.orderdetails2 = conOrderDetail1;
      c4.Prod = pro1;
      c4.Boxnumber = 0.00;
      c4.Piecenumber = 0.00;
      c4.allnumber = 1999.00;
      c4.oldConsumableCount = 1999.00;
      c4.canSelect = true;
      c4.sortBy = true;
      c4.packinglist = 1;
      c4.approbation_No = '';
      c4.expiration_Date = Date.Today();
      c4.boxorpiecein = '';
      c4.boxorpiece = null;
      c4.boxorpieceMap = null;
      c4.concc = null;
      c4.BoxPiece = null;
      c4.hosPro = true;
      pageRecords4.add(c4);
      List<LexSummonsCreatController.ConsumableorderdetailsInfo> consumable = new List<LexSummonsCreatController.ConsumableorderdetailsInfo>();
      LexSummonsCreatController.ConsumableorderdetailsInfo codi = new LexSummonsCreatController.ConsumableorderdetailsInfo();
      codi.check = true;
      codi.hospitalSpecialOffer = true;
      codi.packinglist = 0;
      codi.approbation_No = null;
      codi.expiration_Date = Date.Today();
      codi.boxorpiecein = null;
      codi.orderdetails1 = coc;
      codi.Prod = pro1;
      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
      );
      System.Test.stopTest();
    }
  }

  @isTest
  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'
    );
    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
    );
    insert accountItem2;
    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 = '北京'
      );
      insert 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
      ];
      String accountId = thisUserInfo.accountid;
      String accountName = thisUserInfo.Contact.Account.Name;
      String agencyProType = thisUserInfo.UserPro_Type__c;
      String userWorkLocation = thisUserInfo.Work_Location__c;
      thisUserInfo.UserPro_Type__c = '';
      update thisUserInfo;
      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 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 = '批准';
      createIdSend.Deliver_date__c = Date.today();
      createIdSend.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      createIdSend.Order_type__c = '订单';
      createIdSend.Order_ProType__c = 'ENG';
      createIdSend.SummonsForDirction__c = '测试0001';
      createIdSend.Order_ForDealerText__c = 'Testaccount003';
      createIdSend.Order_ForCustomerText__c = 'Test000';
      createIdSend.SummonsStatus_c__c = '批准';
      createIdSend.Dealer_Info__c = accountItem1.Id;
      createIdSend.Delivery_detail_count__c = 5;

      Consumable_order__c createIdSend1 = new Consumable_order__c();
      createIdSend1.Name = 'testMing2';
      createIdSend1.Order_status__c = '批准';
      createIdSend1.Deliver_date__c = Date.today();
      createIdSend1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      createIdSend1.Order_type__c = '订单';
      createIdSend1.Order_ProType__c = 'ENG';
      createIdSend1.SummonsForDirction__c = '销售给二级经销商';
      createIdSend1.Order_ForDealerText__c = 'Testaccount003';
      createIdSend1.Order_ForCustomerText__c = 'Test000';
      createIdSend1.SummonsStatus_c__c = '价格未定';
      createIdSend1.Dealer_Info__c = accountItem1.Id;
      createIdSend1.Delivery_detail_count__c = 5;
      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;
      coc.Consumable_count__c = 3;
      coc.Consumable_product__c = pro1.Id;
      coc.Box_Piece__c = '个';
      coc.isOutPattern__c = true;
      coc.Consumable_order__c = createIdSend.Id;
      coc.Unitprice_To_agency__c = 999.00;
      coc.Delivery_List_RMB__c = 999.00;
      coc.Shipment_Count__c = 9999.00;
      coc.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;

      Consumable_orderdetails__c coc1 = new Consumable_orderdetails__c();
      coc1.Name = 'Too002';
      coc1.Dealer_Custom_Price__c = 999.00;
      coc1.Consumable_count__c = 3;
      coc1.Consumable_product__c = pro1.Id;
      coc1.Box_Piece__c = '个';
      coc1.isOutPattern__c = true;
      coc1.Consumable_order__c = createIdSend.Id;
      coc1.Unitprice_To_agency__c = 999.00;
      coc1.Delivery_List_RMB__c = 999.00;
      coc1.Shipment_Count__c = null;
      coc1.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;

      Consumable_orderdetails__c coc2 = new Consumable_orderdetails__c();
      coc2.Name = 'Too003';
      coc2.Dealer_Custom_Price__c = 999.00;
      coc2.Consumable_count__c = 3;
      coc2.Consumable_product__c = pro1.Id;
      coc2.Box_Piece__c = '个';
      coc2.isOutPattern__c = true;
      coc2.Consumable_order__c = createIdSend.Id;
      coc2.Unitprice_To_agency__c = 999.00;
      coc2.Delivery_List_RMB__c = 0;
      coc2.Shipment_Count__c = 100.00;
      coc2.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
      Consumable_orderdetails__c coc3 = new Consumable_orderdetails__c();
      coc3.Name = 'Too004';
      coc3.Dealer_Custom_Price__c = 999.00;
      coc3.Consumable_count__c = 3;
      coc3.Consumable_product__c = pro1.Id;
      coc3.Box_Piece__c = '';
      coc3.isOutPattern__c = true;
      coc3.Consumable_order__c = createIdSend1.Id;
      coc3.Unitprice_To_agency__c = 999.00;
      coc3.Delivery_List_RMB__c = 0.00;
      coc3.Shipment_Count__c = 9999.00;
      coc3.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
      Consumable_orderdetails__c coc4 = new Consumable_orderdetails__c();
      coc4.Name = 'Too005';
      coc4.Dealer_Custom_Price__c = 999.00;
      coc4.Consumable_count__c = 3;
      coc4.Consumable_product__c = pro1.Id;
      coc4.Box_Piece__c = '';
      coc4.isOutPattern__c = true;
      coc4.Consumable_order__c = createIdSend1.Id;
      coc4.Unitprice_To_agency__c = 999.00;
      coc4.Delivery_List_RMB__c = 9999.00;
      coc4.Shipment_Count__c = 100.00;
      coc4.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
      Consumable_orderdetails__c coc5 = new Consumable_orderdetails__c();
      coc5.Name = 'Too006';
      coc5.Dealer_Custom_Price__c = 999.00;
      coc5.Consumable_count__c = 3;
      coc5.Consumable_product__c = pro1.Id;
      coc5.Box_Piece__c = '盒';
      coc5.isOutPattern__c = true;
      coc5.Consumable_order__c = createIdSend1.Id;
      coc5.Unitprice_To_agency__c = 999.00;
      coc5.Delivery_List_RMB__c = 9999.00;
      coc5.Shipment_Count__c = 9999.00;
      coc5.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
      Consumable_orderdetails__c coc6 = new Consumable_orderdetails__c();
      coc6.Name = 'Too007';
      coc6.Dealer_Custom_Price__c = 999.00;
      coc6.Consumable_count__c = 3;
      coc6.Consumable_product__c = pro1.Id;
      coc6.Box_Piece__c = '个';
      coc6.isOutPattern__c = true;
      coc6.Consumable_order__c = createIdSend1.Id;
      coc6.Unitprice_To_agency__c = 999.00;
      coc6.Delivery_List_RMB__c = 9999.00;
      coc6.Shipment_Count__c = 9999.00;
      coc6.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
      Consumable_orderdetails__c coc7 = new Consumable_orderdetails__c();
      coc7.Name = 'Too008';
      coc7.Dealer_Custom_Price__c = 999.00;
      coc7.Consumable_count__c = 3;
      coc7.Consumable_product__c = pro1.Id;
      coc7.Box_Piece__c = '盒';
      coc7.isOutPattern__c = true;
      coc7.Consumable_order__c = createIdSend1.Id;
      coc7.Unitprice_To_agency__c = 999.00;
      coc7.Delivery_List_RMB__c = 100;
      coc7.Shipment_Count__c = 0;
      coc7.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
      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';
      conOrderDetail1.Consumable_ZS_order__c = createIdSend.Id;
      conOrderDetail1.Consumable_Product__c = pro1.Id;
      conOrderDetail1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
      conOrderDetail1.Bar_Code__c = '11111';
      conOrderDetail1.Arrive_date__c = Date.today().addDays(1);
      conOrderDetail1.Send_Date__c = null;
      conOrderDetail1.Used_date__c = null;
      conOrderDetail1.Return_date__c = null;
      conOrderDetail1.Consumable_order_minor__c = createIdSend.Id;
      conOrderDetail1.Lose_Flag__c = false;
      conOrderDetail1.Cancellation_Flag__c = false;
      conOrderDetail1.Box_Piece__c = '盒';
      conOrderDetail1.Sterilization_limit__c = Date.Today();
      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;
      c0.oldCheck = false;
      c0.hospitalSpecialOffer = true;
      c0.orderdetails1 = coc;
      c0.orderdetails2 = conOrderDetail1;
      c0.Prod = pro1;
      c0.Boxnumber = 0.00;
      c0.Piecenumber = 0.00;
      c0.allnumber = 1999.00;
      c0.oldConsumableCount = 1999.00;
      c0.canSelect = true;
      c0.sortBy = true;
      c0.packinglist = 1;
      c0.approbation_No = '';
      c0.expiration_Date = Date.Today();
      c0.boxorpiecein = '';
      c0.boxorpiece = null;
      c0.boxorpieceMap = null;
      c0.concc = null;
      c0.BoxPiece = null;
      c0.hosPro = true;
      pageRecords.add(c0);
      List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecords1 = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
      LexSummonsCreatController.ConsumableorderdetailsInfoLwc c1 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
      c1.check = true;
      c1.oldCheck = true;
      c1.hospitalSpecialOffer = true;
      c1.orderdetails1 = coc;
      c1.orderdetails2 = conOrderDetail1;
      c1.Prod = pro1;
      c1.Boxnumber = 0.00;
      c1.Piecenumber = 0.00;
      c1.allnumber = 1999.00;
      c1.oldConsumableCount = 1999.00;
      c1.canSelect = true;
      c1.sortBy = true;
      c1.packinglist = 1;
      c1.approbation_No = '';
      c1.expiration_Date = Date.Today();
      c1.boxorpiecein = '';
      c1.boxorpiece = null;
      c1.boxorpieceMap = null;
      c1.concc = null;
      c1.BoxPiece = null;
      c1.hosPro = true;
      pageRecords1.add(c1);
      List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecords2 = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
      LexSummonsCreatController.ConsumableorderdetailsInfoLwc c2 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
      c2.check = true;
      c2.oldCheck = false;
      c2.hospitalSpecialOffer = true;
      c2.orderdetails1 = coc1;
      c2.orderdetails2 = conOrderDetail1;
      c2.Prod = pro1;
      c2.Boxnumber = 0.00;
      c2.Piecenumber = 0.00;
      c2.allnumber = 1999.00;
      c2.oldConsumableCount = 1999.00;
      c2.canSelect = true;
      c2.sortBy = true;
      c2.packinglist = 1;
      c2.approbation_No = '';
      c2.expiration_Date = Date.Today();
      c2.boxorpiecein = '';
      c2.boxorpiece = null;
      c2.boxorpieceMap = null;
      c2.concc = null;
      c2.BoxPiece = null;
      c2.hosPro = true;
      pageRecords2.add(c2);
      List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecords3 = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
      LexSummonsCreatController.ConsumableorderdetailsInfoLwc c3 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
      c3.check = true;
      c3.oldCheck = true;
      c3.hospitalSpecialOffer = true;
      c3.orderdetails1 = coc2;
      c3.orderdetails2 = conOrderDetail1;
      c3.Prod = pro1;
      c3.Boxnumber = 0.00;
      c3.Piecenumber = 0.00;
      c3.allnumber = 199999.00;
      c3.oldConsumableCount = 1999.00;
      c3.canSelect = true;
      c3.sortBy = true;
      c3.packinglist = 1;
      c3.approbation_No = '';
      c3.expiration_Date = Date.Today();
      c3.boxorpiecein = '';
      c3.boxorpiece = null;
      c3.boxorpieceMap = null;
      c3.concc = null;
      c3.BoxPiece = null;
      c3.hosPro = true;
      pageRecords3.add(c3);
      List<LexSummonsCreatController.ConsumableorderdetailsInfo> consumable = new List<LexSummonsCreatController.ConsumableorderdetailsInfo>();
      LexSummonsCreatController.ConsumableorderdetailsInfo codi = new LexSummonsCreatController.ConsumableorderdetailsInfo();
      codi.check = true;
      codi.hospitalSpecialOffer = true;
      codi.packinglist = 0;
      codi.approbation_No = null;
      codi.expiration_Date = Date.Today();
      codi.boxorpiecein = null;
      codi.orderdetails1 = coc;
      codi.Prod = pro1;
      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
      );
      System.Test.stopTest();
    }
  }

  @isTest
  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
    );
    insert accountItem1;
    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
    );
    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 = '北京'
      );
      insert 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
      ];
      String accountId = thisUserInfo.accountid;
      String accountName = thisUserInfo.Contact.Account.Name;
      String agencyProType = thisUserInfo.UserPro_Type__c;
      String userWorkLocation = thisUserInfo.Work_Location__c;
      thisUserInfo.UserPro_Type__c = '';
      update thisUserInfo;
      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 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 = '批准';
      createIdSend.Deliver_date__c = Date.today();
      createIdSend.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      createIdSend.Order_type__c = '订单';
      createIdSend.Order_ProType__c = 'ENG';
      createIdSend.SummonsForDirction__c = 'Test123456';
      createIdSend.Order_ForDealerText__c = '';
      createIdSend.Order_ForDealer__c = accountItem1.Id;
      createIdSend.Order_ForCustomerText__c = '';
      createIdSend.SummonsStatus_c__c = '批准';
      createIdSend.Dealer_Info__c = accountItem1.Id;
      createIdSend.Delivery_detail_count__c = 5;

      Consumable_order__c createIdSend1 = new Consumable_order__c();
      createIdSend.Name = 'testMing1';
      createIdSend.Order_status__c = '批准';
      createIdSend.Deliver_date__c = Date.today();
      createIdSend.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      createIdSend.Order_type__c = '订单';
      createIdSend.Order_ProType__c = 'ENG';
      createIdSend.SummonsForDirction__c = '互相调货';
      createIdSend.Order_ForDealerText__c = 'Test';
      createIdSend.Order_ForDealer__c = accountItem1.Id;
      createIdSend.Order_ForCustomerText__c = '';
      createIdSend.SummonsStatus_c__c = '';
      createIdSend.Dealer_Info__c = accountItem1.Id;
      createIdSend.Delivery_detail_count__c = 5;

      Consumable_order__c createIdSend2 = new Consumable_order__c();
      createIdSend2.Name = 'testMing1';
      createIdSend2.Order_status__c = '批准';
      createIdSend2.Deliver_date__c = Date.today();
      createIdSend2.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      createIdSend2.Order_type__c = '订单';
      createIdSend2.Order_ProType__c = 'ENG';
      createIdSend2.SummonsForDirction__c = '直接销售给医院';
      createIdSend2.Order_ForDealerText__c = '';
      createIdSend2.Order_ForDealer__c = accountItem1.Id;
      createIdSend2.Order_ForCustomerText__c = '';
      createIdSend2.SummonsStatus_c__c = '价格未定';
      createIdSend2.Dealer_Info__c = accountItem1.Id;
      createIdSend2.Delivery_detail_count__c = 5;
      insert new List<Consumable_order__c>{
        createIdSend,
        createIdSend1,
        createIdSend2
      };

      Consumable_orderdetails__c coc = new Consumable_orderdetails__c();
      coc.Name = 'Too001';
      coc.Dealer_Custom_Price__c = 999.00;
      coc.Consumable_count__c = 3;
      coc.Consumable_product__c = pro1.Id;
      coc.Box_Piece__c = '盒';
      coc.isOutPattern__c = true;
      coc.Consumable_order__c = createIdSend.Id;
      coc.Unitprice_To_agency__c = 999.00;
      coc.Delivery_List_RMB__c = 999.00;
      coc.Shipment_Count__c = 10000;
      coc.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
      Consumable_orderdetails__c coc1 = new Consumable_orderdetails__c();
      coc1.Name = 'Too001';
      coc1.Dealer_Custom_Price__c = 999.00;
      coc1.Consumable_count__c = 3;
      coc1.Consumable_product__c = pro1.Id;
      coc1.Box_Piece__c = '盒';
      coc1.isOutPattern__c = true;
      coc1.Consumable_order__c = createIdSend.Id;
      coc1.Unitprice_To_agency__c = 999.00;
      coc1.Delivery_List_RMB__c = -999.00;
      coc1.Shipment_Count__c = 10000;
      coc1.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
      Consumable_orderdetails__c coc2 = new Consumable_orderdetails__c();
      coc2.Name = 'Too001';
      coc2.Dealer_Custom_Price__c = 999.00;
      coc2.Consumable_count__c = 3;
      coc2.Consumable_product__c = pro1.Id;
      coc2.Box_Piece__c = '个';
      coc2.isOutPattern__c = true;
      coc2.Consumable_order__c = createIdSend.Id;
      coc2.Unitprice_To_agency__c = 999.00;
      coc2.Delivery_List_RMB__c = null;
      coc2.Shipment_Count__c = 10000;
      coc2.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
      Consumable_orderdetails__c coc3 = new Consumable_orderdetails__c();
      coc3.Name = 'Too001';
      coc3.Dealer_Custom_Price__c = 999.00;
      coc3.Consumable_count__c = 3;
      coc3.Consumable_product__c = pro1.Id;
      coc3.Box_Piece__c = '';
      coc3.isOutPattern__c = true;
      coc3.Consumable_order__c = createIdSend2.Id;
      coc3.Unitprice_To_agency__c = 999.00;
      coc3.Delivery_List_RMB__c = 0;
      coc3.Shipment_Count__c = 10000;
      coc3.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
      Consumable_orderdetails__c coc4 = new Consumable_orderdetails__c();
      coc4.Name = 'Too001';
      coc4.Dealer_Custom_Price__c = 999.00;
      coc4.Consumable_count__c = 3;
      coc4.Consumable_product__c = pro1.Id;
      coc4.Box_Piece__c = '';
      coc4.isOutPattern__c = true;
      coc4.Consumable_order__c = createIdSend2.Id;
      coc4.Unitprice_To_agency__c = 999.00;
      coc4.Delivery_List_RMB__c = 0;
      coc4.Shipment_Count__c = 10000;
      coc4.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
      Consumable_orderdetails__c coc5 = new Consumable_orderdetails__c();
      coc5.Name = 'Too001';
      coc5.Dealer_Custom_Price__c = 999.00;
      coc5.Consumable_count__c = 3;
      coc5.Consumable_product__c = pro1.Id;
      coc5.Box_Piece__c = '盒';
      coc5.isOutPattern__c = true;
      coc5.Consumable_order__c = createIdSend2.Id;
      coc5.Unitprice_To_agency__c = 999.00;
      coc5.Delivery_List_RMB__c = 100;
      coc5.Shipment_Count__c = 10000;
      coc5.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
      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';
      conOrderDetail1.Consumable_ZS_order__c = createIdSend.Id;
      conOrderDetail1.Consumable_Product__c = pro1.Id;
      conOrderDetail1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
      conOrderDetail1.Bar_Code__c = '11111';
      conOrderDetail1.Arrive_date__c = Date.today().addDays(1);
      conOrderDetail1.Send_Date__c = null;
      conOrderDetail1.Used_date__c = null;
      conOrderDetail1.Return_date__c = null;
      conOrderDetail1.Consumable_order_minor__c = createIdSend.Id;
      conOrderDetail1.Lose_Flag__c = false;
      conOrderDetail1.Box_Piece__c = '盒';
      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 List<hospitalprice__c>{ hp1 };

      List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecordsList = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
      LexSummonsCreatController.ConsumableorderdetailsInfoLwc cod = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
      cod.check = true;
      cod.oldCheck = true;
      cod.hospitalSpecialOffer = true;
      cod.orderdetails1 = coc;
      cod.orderdetails2 = conOrderDetail1;
      cod.Prod = pro1;
      cod.Boxnumber = 0.00;
      cod.Piecenumber = 0.00;
      cod.allnumber = 1999.00;
      cod.oldConsumableCount = 1999.00;
      cod.canSelect = true;
      cod.sortBy = true;
      cod.packinglist = 1;
      cod.approbation_No = '';
      cod.expiration_Date = Date.Today();
      cod.boxorpiecein = '';
      cod.boxorpiece = null;
      cod.boxorpieceMap = null;
      cod.concc = null;
      cod.BoxPiece = null;
      cod.hosPro = true;
      pageRecordsList.add(cod);
      List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecords = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
      LexSummonsCreatController.ConsumableorderdetailsInfoLwc c7 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
      c7.check = false;
      c7.oldCheck = true;
      c7.hospitalSpecialOffer = false;
      c7.orderdetails1 = coc1;
      c7.orderdetails2 = conOrderDetail1;
      c7.Prod = pro1;
      c7.Boxnumber = 0.00;
      c7.Piecenumber = 0.00;
      c7.allnumber = 1999.00;
      c7.oldConsumableCount = 1999.00;
      c7.canSelect = true;
      c7.sortBy = true;
      c7.packinglist = 1;
      c7.approbation_No = '';
      c7.expiration_Date = Date.Today();
      c7.boxorpiecein = '';
      c7.boxorpiece = null;
      c7.boxorpieceMap = null;
      c7.concc = null;
      c7.BoxPiece = null;
      c7.hosPro = true;
      pageRecords.add(c7);
      List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecords2 = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
      LexSummonsCreatController.ConsumableorderdetailsInfoLwc c9 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
      c9.check = true;
      c9.oldCheck = true;
      c9.hospitalSpecialOffer = true;
      c9.orderdetails1 = coc3;
      c9.orderdetails2 = conOrderDetail1;
      c9.Prod = pro1;
      c9.Boxnumber = 0.00;
      c9.Piecenumber = 0.00;
      c9.allnumber = 1999.00;
      c9.oldConsumableCount = 1999.00;
      c9.canSelect = true;
      c9.sortBy = true;
      c9.packinglist = 1;
      c9.approbation_No = '';
      c9.expiration_Date = Date.Today();
      c9.boxorpiecein = '';
      c9.boxorpiece = null;
      c9.boxorpieceMap = null;
      c9.concc = null;
      c9.BoxPiece = null;
      c9.hosPro = true;
      pageRecords2.add(c9);
      List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecords3 = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
      LexSummonsCreatController.ConsumableorderdetailsInfoLwc c10 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
      c10.check = true;
      c10.oldCheck = false;
      c10.hospitalSpecialOffer = true;
      c10.orderdetails1 = coc4;
      c10.orderdetails2 = conOrderDetail1;
      c10.Prod = pro1;
      c10.Boxnumber = 0.00;
      c10.Piecenumber = 0.00;
      c10.allnumber = 1999.00;
      c10.oldConsumableCount = 1999.00;
      c10.canSelect = true;
      c10.sortBy = true;
      c10.packinglist = 1;
      c10.approbation_No = '';
      c10.expiration_Date = Date.Today();
      c10.boxorpiecein = '';
      c10.boxorpiece = null;
      c10.boxorpieceMap = null;
      c10.concc = null;
      c10.BoxPiece = null;
      c10.hosPro = true;
      pageRecords3.add(c10);
      List<LexSummonsCreatController.ConsumableorderdetailsInfo> consumable = new List<LexSummonsCreatController.ConsumableorderdetailsInfo>();
      LexSummonsCreatController.ConsumableorderdetailsInfo codi = new LexSummonsCreatController.ConsumableorderdetailsInfo();
      codi.check = true;
      codi.oldCheck = true;
      codi.hospitalSpecialOffer = true;
      codi.packinglist = 0;
      codi.approbation_No = null;
      codi.expiration_Date = Date.Today();
      codi.boxorpiecein = null;
      codi.orderdetails1 = coc;
      codi.Prod = pro1;
      consumable.add(codi);
      List<LexSummonsCreatController.ConsumableorderdetailsInfo> consumableList = new List<LexSummonsCreatController.ConsumableorderdetailsInfo>();
      LexSummonsCreatController.ConsumableorderdetailsInfo codi1 = new LexSummonsCreatController.ConsumableorderdetailsInfo();
      codi1.check = false;
      codi1.oldCheck = true;
      codi1.hospitalSpecialOffer = false;
      codi1.packinglist = 0;
      codi1.approbation_No = null;
      codi1.expiration_Date = Date.Today();
      codi1.boxorpiecein = null;
      codi1.orderdetails1 = coc;
      codi1.Prod = pro1;
      consumableList.add(codi1);
      Integer size = Integer.valueOf(System.Label.orderdetLimitsize);
      String ESetId = createIdSend.Id;
      String statusEdit = 'Test';
      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
      );
      System.Test.stopTest();
    }
  }
  @isTest
  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
    );
    insert accountItem1;
    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
    );
    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 = '北京'
      );
      insert 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
      ];
      String accountId = thisUserInfo.accountid;
      String accountName = thisUserInfo.Contact.Account.Name;
      String agencyProType = thisUserInfo.UserPro_Type__c;
      String userWorkLocation = thisUserInfo.Work_Location__c;
      thisUserInfo.UserPro_Type__c = '';
      update thisUserInfo;
      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 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 = '批准';
      createIdSend.Deliver_date__c = Date.today();
      createIdSend.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      createIdSend.Order_type__c = '订单';
      createIdSend.Order_ProType__c = 'ENG';
      createIdSend.SummonsForDirction__c = '直接销售给医院';
      createIdSend.Order_ForDealerText__c = 'Test';
      createIdSend.Order_ForCustomerText__c = 'Test';
      createIdSend.SummonsStatus_c__c = '批准';
      createIdSend.Dealer_Info__c = accountItem1.Id;
      createIdSend.Delivery_detail_count__c = 5;

      Consumable_order__c createIdSend1 = new Consumable_order__c();
      createIdSend1.Name = 'testMing1';
      createIdSend1.Order_status__c = '批准';
      createIdSend1.Deliver_date__c = Date.today();
      createIdSend1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      createIdSend1.Order_type__c = '订单';
      createIdSend1.Order_ProType__c = 'ENG';
      createIdSend1.SummonsForDirction__c = '医院试用';
      createIdSend1.Order_ForDealerText__c = 'Test';
      createIdSend1.Order_ForCustomerText__c = '';
      createIdSend1.SummonsStatus_c__c = '批准';
      createIdSend1.Dealer_Info__c = accountItem1.Id;
      createIdSend1.Delivery_detail_count__c = 5;

      Consumable_order__c createIdSend2 = new Consumable_order__c();
      createIdSend2.Name = 'testMing1';
      createIdSend2.Order_status__c = '批准';
      createIdSend2.Deliver_date__c = Date.today();
      createIdSend2.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      createIdSend2.Order_type__c = '订单';
      createIdSend2.Order_ProType__c = 'ENG';
      createIdSend2.SummonsForDirction__c = '互相调货';
      createIdSend2.Order_ForDealerText__c = '';
      createIdSend2.Order_ForCustomerText__c = 'Test';
      createIdSend2.SummonsStatus_c__c = '批准';
      createIdSend2.Dealer_Info__c = accountItem1.Id;
      createIdSend2.Delivery_detail_count__c = 5;
      insert new List<Consumable_order__c>{
        createIdSend,
        createIdSend1,
        createIdSend2
      };

      Consumable_orderdetails__c coc = new Consumable_orderdetails__c();
      coc.Name = 'Too001';
      coc.Dealer_Custom_Price__c = 999.00;
      coc.Consumable_count__c = 3;
      coc.Consumable_product__c = pro1.Id;
      coc.Box_Piece__c = '盒';
      coc.isOutPattern__c = true;
      coc.Consumable_order__c = createIdSend.Id;
      coc.Unitprice_To_agency__c = 999.00;
      coc.Delivery_List_RMB__c = 999.00;
      coc.Shipment_Count__c = null;
      coc.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
      Consumable_orderdetails__c coc2 = new Consumable_orderdetails__c();
      coc2.Name = 'Too001';
      coc2.Dealer_Custom_Price__c = 999.00;
      coc2.Consumable_count__c = 3;
      coc2.Consumable_product__c = pro1.Id;
      coc2.Box_Piece__c = '个';
      coc2.isOutPattern__c = true;
      coc2.Consumable_order__c = createIdSend.Id;
      coc2.Unitprice_To_agency__c = 999.00;
      coc2.Delivery_List_RMB__c = 0;
      coc2.Shipment_Count__c = 0;
      coc2.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
      insert new List<Consumable_orderdetails__c>{ coc, coc2 };

      Consumable_order_details2__c conOrderDetail1 = new Consumable_order_details2__c();
      conOrderDetail1.Name = 'OCM_01_001001';
      conOrderDetail1.Consumable_ZS_order__c = createIdSend.Id;
      conOrderDetail1.Consumable_Product__c = pro1.Id;
      conOrderDetail1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
      conOrderDetail1.Bar_Code__c = '11111';
      conOrderDetail1.Arrive_date__c = Date.today().addDays(1);
      conOrderDetail1.Send_Date__c = null;
      conOrderDetail1.Used_date__c = null;
      conOrderDetail1.Return_date__c = null;
      conOrderDetail1.Consumable_order_minor__c = createIdSend.Id;
      conOrderDetail1.Lose_Flag__c = false;
      conOrderDetail1.Box_Piece__c = '盒';
      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 List<hospitalprice__c>{ hp1 };

      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 List<Attachment>{ attach };

      System.Test.startTest();
      List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecordsLwcLwc = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
      LexSummonsCreatController.ConsumableorderdetailsInfoLwc c5 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
      c5.check = true;
      c5.hospitalSpecialOffer = true;
      c5.orderdetails1 = coc;
      c5.allnumber = 1999.00;
      pageRecordsLwcLwc.add(c5);
      List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecordsList = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
      LexSummonsCreatController.ConsumableorderdetailsInfoLwc c8 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
      c8.check = true;
      c8.hospitalSpecialOffer = true;
      c8.orderdetails1 = coc2;
      c8.allnumber = 1999.00;
      pageRecordsList.add(c8);
      List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecords = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
      LexSummonsCreatController.ConsumableorderdetailsInfoLwc c6 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
      c6.check = false;
      c6.hospitalSpecialOffer = false;
      c6.orderdetails1 = coc;
      c6.allnumber = 1999.00;
      pageRecords.add(c6);
      List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecordsLwc = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
      LexSummonsCreatController.ConsumableorderdetailsInfoLwc c7 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
      c7.check = true;
      c7.oldCheck = true;
      c7.hospitalSpecialOffer = true;
      c7.orderdetails1 = coc;
      c7.orderdetails2 = conOrderDetail1;
      c7.Prod = pro1;
      c7.Boxnumber = 0.00;
      c7.Piecenumber = 0.00;
      c7.allnumber = 1999.00;
      c7.oldConsumableCount = 1999.00;
      c7.canSelect = true;
      c7.sortBy = true;
      c7.packinglist = 1;
      c7.approbation_No = '';
      c7.expiration_Date = Date.Today();
      c7.boxorpiecein = '';
      c7.boxorpiece = null;
      c7.boxorpieceMap = null;
      c7.concc = null;
      c7.BoxPiece = null;
      c7.hosPro = true;
      pageRecordsLwc.add(c7);

      List<LexSummonsCreatController.ConsumableorderdetailsInfo> consumable = new List<LexSummonsCreatController.ConsumableorderdetailsInfo>();
      LexSummonsCreatController.ConsumableorderdetailsInfo codi = new LexSummonsCreatController.ConsumableorderdetailsInfo();
      codi.check = true;
      codi.oldCheck = true;
      codi.hospitalSpecialOffer = true;
      codi.packinglist = 0;
      codi.approbation_No = null;
      codi.expiration_Date = Date.Today();
      codi.boxorpiecein = null;
      codi.orderdetails1 = coc;
      codi.Prod = pro1;
      LexSummonsCreatController.ConsumableorderdetailsInfo codi1 = new LexSummonsCreatController.ConsumableorderdetailsInfo();
      codi1.check = false;
      codi1.oldCheck = true;
      codi1.hospitalSpecialOffer = false;
      codi1.packinglist = 0;
      codi1.approbation_No = null;
      codi1.expiration_Date = Date.Today();
      codi1.boxorpiecein = null;
      codi1.orderdetails1 = coc;
      codi1.Prod = pro1;
      consumable.add(codi);

      Integer size = Integer.valueOf(System.Label.orderdetLimitsize);
      String ESetId = createIdSend.Id;
      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.ConsumableorderdetailsInfo con = new LexSummonsCreatController.ConsumableorderdetailsInfo(
        attach
      );
      con.concc = attach;
      con.hospitalSpecialOffer = false;
      con.hosPro = false;
      System.Test.stopTest();
    }
  }

  @isTest
  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
    );
    insert accountItem1;
    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
    );
    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 = '北京'
      );
      insert 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
      ];
      String accountId = thisUserInfo.accountid;
      String accountName = thisUserInfo.Contact.Account.Name;
      String agencyProType = thisUserInfo.UserPro_Type__c;
      String userWorkLocation = thisUserInfo.Work_Location__c;
      thisUserInfo.UserPro_Type__c = '';
      update thisUserInfo;
      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 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 = '批准';
      createIdSend.Deliver_date__c = Date.today();
      createIdSend.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      createIdSend.Order_type__c = '订单';
      createIdSend.Order_ProType__c = 'ENG';
      createIdSend.SummonsForDirction__c = '互相调货';
      createIdSend.Order_ForDealerText__c = '';
      createIdSend.Order_ForCustomerText__c = '';
      createIdSend.SummonsStatus_c__c = '';
      createIdSend.Dealer_Info__c = accountItem1.Id;
      createIdSend.Delivery_detail_count__c = 5;

      Consumable_order__c createIdSend1 = new Consumable_order__c();
      createIdSend1.Name = 'testMing1';
      createIdSend1.Order_status__c = '批准';
      createIdSend1.Deliver_date__c = Date.today();
      createIdSend1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      createIdSend1.Order_type__c = '订单';
      createIdSend1.Order_ProType__c = 'ENG';
      createIdSend1.SummonsForDirction__c = '互相调货';
      createIdSend1.Order_ForDealerText__c = '';
      createIdSend1.Order_ForCustomerText__c = '';
      createIdSend1.SummonsStatus_c__c = '';
      createIdSend1.Arrive_Order__c = createIdSend.Id;
      createIdSend1.Order_ForDealerTextID__c = accountItem1.Id;
      createIdSend1.Dealer_Info__c = accountItem1.Id;
      createIdSend1.Delivery_detail_count__c = 5;
      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;
      coc.Consumable_count__c = 3;
      coc.Consumable_product__c = pro1.Id;
      coc.Box_Piece__c = '盒';
      coc.isOutPattern__c = true;
      coc.Consumable_order__c = createIdSend.Id;
      coc.Unitprice_To_agency__c = 999.00;
      coc.Delivery_List_RMB__c = 999.00;
      coc.Shipment_Count__c = null;
      coc.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
      Consumable_orderdetails__c coc1 = new Consumable_orderdetails__c();
      coc1.Name = 'Too001';
      coc1.Dealer_Custom_Price__c = 999.00;
      coc1.Consumable_count__c = 3;
      coc1.Consumable_product__c = pro1.Id;
      coc1.Box_Piece__c = '盒';
      coc1.isOutPattern__c = true;
      coc1.Consumable_order__c = createIdSend.Id;
      coc1.Unitprice_To_agency__c = 999.00;
      coc1.Delivery_List_RMB__c = null;
      coc1.Shipment_Count__c = 10000;
      coc1.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
      insert new List<Consumable_orderdetails__c>{ coc, coc1 };

      Consumable_order_details2__c conOrderDetail1 = new Consumable_order_details2__c();
      conOrderDetail1.Name = 'OCM_01_001001';
      conOrderDetail1.Consumable_ZS_order__c = createIdSend.Id;
      conOrderDetail1.Consumable_Product__c = pro1.Id;
      conOrderDetail1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
      conOrderDetail1.Bar_Code__c = '11111';
      conOrderDetail1.Arrive_date__c = Date.today().addDays(1);
      conOrderDetail1.Send_Date__c = null;
      conOrderDetail1.Used_date__c = null;
      conOrderDetail1.Return_date__c = null;
      conOrderDetail1.Consumable_order_minor__c = createIdSend.Id;
      conOrderDetail1.Lose_Flag__c = false;
      conOrderDetail1.Box_Piece__c = '盒';
      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 List<hospitalprice__c>{ hp1 };

      Integer size = Integer.valueOf(System.Label.orderdetLimitsize);
      String ESetId = createIdSend.Id;
      String statusEdit = 'Test';
      String arrive = createIdSend.Id;

      List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecordsLwc = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
      LexSummonsCreatController.ConsumableorderdetailsInfoLwc c7 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
      c7.check = true;
      c7.oldCheck = true;
      c7.hospitalSpecialOffer = true;
      c7.orderdetails1 = coc;
      c7.orderdetails2 = conOrderDetail1;
      c7.Prod = pro1;
      c7.Boxnumber = 0.00;
      c7.Piecenumber = 0.00;
      c7.allnumber = 1999.00;
      c7.oldConsumableCount = 1999.00;
      c7.canSelect = true;
      c7.sortBy = true;
      c7.packinglist = 1;
      c7.approbation_No = '';
      c7.expiration_Date = Date.Today();
      c7.boxorpiecein = '';
      c7.boxorpiece = null;
      c7.boxorpieceMap = null;
      c7.concc = null;
      c7.BoxPiece = null;
      c7.hosPro = true;
      pageRecordsLwc.add(c7);
      List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecords1 = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
      LexSummonsCreatController.ConsumableorderdetailsInfoLwc c8 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
      c8.check = true;
      c8.oldCheck = true;
      c8.hospitalSpecialOffer = true;
      c8.orderdetails1 = coc1;
      c8.orderdetails2 = conOrderDetail1;
      c8.Prod = null;
      c8.Boxnumber = 0.00;
      c8.Piecenumber = 0.00;
      c8.allnumber = 1999.00;
      c8.oldConsumableCount = 1999.00;
      c8.canSelect = true;
      c8.sortBy = true;
      c8.packinglist = 1;
      c8.approbation_No = '';
      c8.expiration_Date = Date.Today();
      c8.boxorpiecein = '';
      c8.boxorpiece = null;
      c8.boxorpieceMap = null;
      c8.concc = null;
      c8.BoxPiece = null;
      c8.hosPro = true;
      pageRecords1.add(c8);

      List<LexSummonsCreatController.ConsumableorderdetailsInfo> consumable = new List<LexSummonsCreatController.ConsumableorderdetailsInfo>();
      LexSummonsCreatController.ConsumableorderdetailsInfo codi = new LexSummonsCreatController.ConsumableorderdetailsInfo();
      codi.check = true;
      codi.oldCheck = true;
      codi.hospitalSpecialOffer = true;
      codi.packinglist = 0;
      codi.approbation_No = null;
      codi.expiration_Date = Date.Today();
      codi.boxorpiecein = null;
      codi.orderdetails1 = coc;
      codi.Prod = pro1;
      LexSummonsCreatController.ConsumableorderdetailsInfo codi1 = new LexSummonsCreatController.ConsumableorderdetailsInfo();
      codi1.check = false;
      codi1.oldCheck = true;
      codi1.hospitalSpecialOffer = false;
      codi1.packinglist = 0;
      codi1.approbation_No = null;
      codi1.expiration_Date = Date.Today();
      codi1.boxorpiecein = null;
      codi1.orderdetails1 = coc;
      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
      );
      System.Test.stopTest();
    }
  }

  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'
    );
    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
    );
    insert accountItem2;
    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 = '北京'
      );
      insert 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
      ];
      String accountId = thisUserInfo.accountid;
      String accountName = thisUserInfo.Contact.Account.Name;
      String agencyProType = thisUserInfo.UserPro_Type__c;
      String userWorkLocation = thisUserInfo.Work_Location__c;
      thisUserInfo.UserPro_Type__c = '';
      update thisUserInfo;
      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 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 = '批准';
      createIdSend.Deliver_date__c = Date.today();
      createIdSend.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      createIdSend.Order_type__c = '订单';
      createIdSend.Order_ProType__c = 'ENG';
      createIdSend.SummonsForDirction__c = '测试0001';
      createIdSend.Order_ForDealerText__c = 'Testaccount003';
      createIdSend.Order_ForCustomerText__c = 'Test000';
      createIdSend.SummonsStatus_c__c = '批准';
      createIdSend.orderPattern__c = 'hospitalorder';
      createIdSend.Dealer_Info__c = accountItem1.Id;
      createIdSend.Delivery_detail_count__c = 5;

      Consumable_order__c createIdSend3 = new Consumable_order__c();
      createIdSend3.Name = 'testMing123456';
      createIdSend3.Order_status__c = '批准';
      createIdSend3.Deliver_date__c = Date.today();
      createIdSend3.Arrive_Order__c = createIdSend.Id;
      createIdSend3.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      createIdSend3.Order_type__c = '订单';
      createIdSend3.Order_ProType__c = 'ENG';
      createIdSend3.SummonsForDirction__c = '互相调货';
      createIdSend3.Order_ForDealerText__c = '';
      createIdSend3.Order_ForCustomerText__c = 'Test001';
      createIdSend3.SummonsStatus_c__c = '批准';
      createIdSend3.Dealer_Info__c = accountItem1.Id;
      createIdSend3.Delivery_detail_count__c = 5;
      //到货
      Consumable_order__c createIdArrived = new Consumable_order__c();
      createIdArrived.Name = 'testMing2';
      createIdArrived.Order_status__c = '批准';
      createIdArrived.Deliver_date__c = Date.today();
      createIdArrived.RecordTypeid = System.Label.RT_ConOrder_Arrive;
      createIdArrived.Order_type__c = '订单';
      createIdArrived.Order_ProType__c = 'ET';
      createIdArrived.Arrive_Order__c = createIdSend.Id;
      createIdArrived.SummonsStatus_c__c = '已提交';
      createIdArrived.orderPattern__c = 'promotionorder';
      createIdArrived.Dealer_Info__c = accountItem1.Id;
      createIdArrived.Delivery_detail_count__c = 5;
      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;
      coc.Consumable_count__c = 3;
      coc.Consumable_product__c = pro1.Id;
      coc.Box_Piece__c = '盒';
      coc.isOutPattern__c = true;
      coc.Consumable_order__c = createIdSend.Id;
      coc.Unitprice_To_agency__c = 999.00;
      coc.Delivery_List_RMB__c = -999.00;
      coc.Shipment_Count__c = 9999.00;
      coc.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;

      Consumable_orderdetails__c coc1 = new Consumable_orderdetails__c();
      coc1.Name = 'Too001';
      coc1.Dealer_Custom_Price__c = 999.00;
      coc1.Consumable_count__c = 3;
      coc1.Consumable_product__c = pro1.Id;
      coc1.Box_Piece__c = '盒';
      coc1.isOutPattern__c = true;
      coc1.Consumable_order__c = createIdSend3.Id;
      coc1.Unitprice_To_agency__c = 999.00;
      coc1.Delivery_List_RMB__c = 999.00;
      coc1.Shipment_Count__c = 9999.00;
      coc1.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
      insert new List<Consumable_orderdetails__c>{ coc, coc1 };

      Consumable_order_details2__c conOrderDetail1 = new Consumable_order_details2__c();
      conOrderDetail1.Name = 'OCM_01_001001';
      conOrderDetail1.Consumable_ZS_order__c = createIdSend.Id;
      conOrderDetail1.Consumable_Product__c = pro1.Id;
      conOrderDetail1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
      conOrderDetail1.Bar_Code__c = '11111';
      conOrderDetail1.Arrive_date__c = Date.today().addDays(1);
      conOrderDetail1.Send_Date__c = null;
      conOrderDetail1.Used_date__c = null;
      conOrderDetail1.Return_date__c = null;
      conOrderDetail1.Consumable_Arrived_order__c = createIdSend.Id;
      conOrderDetail1.Consumable_order_minor__c = createIdSend.Id;
      conOrderDetail1.Lose_Flag__c = false;
      conOrderDetail1.Cancellation_Flag__c = false;
      conOrderDetail1.exchangeOutPattern__c = true;
      conOrderDetail1.Box_Piece__c = '盒';
      conOrderDetail1.Sterilization_limit__c = Date.Today();

      Consumable_order_details2__c conOrderDetail2 = new Consumable_order_details2__c();
      conOrderDetail2.Name = 'OCM_01_001002';
      conOrderDetail2.Consumable_ZS_order__c = createIdArrived.Id;
      conOrderDetail2.Consumable_Product__c = pro1.Id;
      conOrderDetail2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
      conOrderDetail2.Bar_Code__c = '22222';
      conOrderDetail2.Arrive_date__c = Date.today().addDays(1);
      conOrderDetail2.Send_Date__c = null;
      conOrderDetail2.Used_date__c = null;
      conOrderDetail2.Return_date__c = null;
      conOrderDetail2.Consumable_Arrived_order__c = createIdArrived.Id;
      conOrderDetail2.Consumable_order_minor__c = createIdArrived.Id;
      conOrderDetail2.Lose_Flag__c = false;
      conOrderDetail2.exchangeOutPattern__c = false;
      conOrderDetail2.Cancellation_Flag__c = false;
      conOrderDetail2.Box_Piece__c = '个';
      conOrderDetail2.Sterilization_limit__c = Date.Today();
      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;
      c6.oldCheck = true;
      c6.hospitalSpecialOffer = true;
      c6.orderdetails1 = coc1;
      c6.orderdetails2 = conOrderDetail1;
      c6.Prod = pro1;
      c6.Boxnumber = 0.00;
      c6.Piecenumber = 0.00;
      c6.allnumber = 1999.00;
      c6.oldConsumableCount = 1999.00;
      c6.canSelect = true;
      c6.sortBy = true;
      c6.packinglist = 1;
      c6.approbation_No = '';
      c6.expiration_Date = Date.Today();
      c6.boxorpiecein = '';
      c6.boxorpiece = null;
      c6.boxorpieceMap = null;
      c6.concc = null;
      c6.BoxPiece = null;
      c6.hosPro = true;
      pageRecords.add(c6);
      List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pageRecords1 = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
      LexSummonsCreatController.ConsumableorderdetailsInfoLwc c111 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
      c111.check = true;
      c111.oldCheck = true;
      c111.hospitalSpecialOffer = false;
      c111.orderdetails1 = coc1;
      c111.orderdetails2 = conOrderDetail1;
      c111.Prod = pro1;
      c111.Boxnumber = 0.00;
      c111.Piecenumber = 0.00;
      c111.allnumber = 1999.00;
      c111.oldConsumableCount = 1999.00;
      c111.canSelect = true;
      c111.sortBy = true;
      c111.packinglist = 1;
      c111.approbation_No = '';
      c111.expiration_Date = Date.Today();
      c111.boxorpiecein = '';
      c111.boxorpiece = null;
      c111.boxorpieceMap = null;
      c111.concc = null;
      c111.BoxPiece = null;
      c111.hosPro = true;
      pageRecords1.add(c111);
      List<LexSummonsCreatController.ConsumableorderdetailsInfo> consumable = new List<LexSummonsCreatController.ConsumableorderdetailsInfo>();
      LexSummonsCreatController.ConsumableorderdetailsInfo codi = new LexSummonsCreatController.ConsumableorderdetailsInfo();
      codi.check = true;
      codi.hospitalSpecialOffer = true;
      codi.packinglist = 0;
      codi.approbation_No = null;
      codi.expiration_Date = Date.Today();
      codi.boxorpiecein = null;
      codi.orderdetails1 = coc;
      codi.Prod = pro1;
      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.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
      );
      List<LexSummonsCreatController.ConsumableorderdetailsInfo> cro = new List<LexSummonsCreatController.ConsumableorderdetailsInfo>();
      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 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())) {
      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 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;
      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';
      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();
      LexSummonsCreatController.init(Order1.Id, 'edit', 10, 1, '');
      List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc> pList = new List<LexSummonsCreatController.ConsumableorderdetailsInfoLwc>();
      LexSummonsCreatController.ConsumableorderdetailsInfoLwc p = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
      p.check = true;
      p.oldcheck = true;
      p.hospitalSpecialOffer = true;
      p.orderdetails1 = Orderdet;
      p.orderdetails2 = Orderdet1;
      p.Prod = pro1;
      p.Boxnumber = 2;
      p.Piecenumber = 2;
      pList.add(p);
      List<LexSummonsCreatController.ConsumableorderdetailsInfo> consumable = new List<LexSummonsCreatController.ConsumableorderdetailsInfo>();
      LexSummonsCreatController.ConsumableorderdetailsInfo codi = new LexSummonsCreatController.ConsumableorderdetailsInfo();
      codi.check = true;
      codi.hospitalSpecialOffer = true;
      codi.packinglist = 0;
      codi.approbation_No = null;
      codi.expiration_Date = Date.Today();
      codi.boxorpiecein = null;
      codi.orderdetails1 = Orderdet;
      codi.orderdetails2 = Orderdet1;
      codi.Prod = pro1;
      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',
        ''
      );
      Orderdet.Box_Piece__c = '个';
      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();
    }
  }

  @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 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())) {
      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 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;
      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';
      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();
      LexSummonsCreatController.init(Order1.Id, 'edit', 10, 1, '');
      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 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())) {
      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 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;
      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';
      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();
      LexSummonsCreatController.init('', 'edit', 10, 1, Order1.Id);
      System.Test.stopTest();
    }
  }
}
