@isTest
private class LexSaleOrderControllerTest {
    public static Map<String, String> orderpieceorboxMap;
    public static Map<String, Decimal> orderpriceMap;
<<<<<<< HEAD
    public static Map<String, Decimal> orderagencypriceMap;
=======
    public static Map<String, Decimal> orderagencypriceMap ;
>>>>>>> LEXCommunityLiJun
    public static Map<String, Decimal> orderdetCountMap;
    public static Map<String, String> existIdMap;
    public static Map<String, String> errorIdMap;
    public static Map<String, String> allMap;
    @isTest
<<<<<<< HEAD
    static void testInit() {
        Account accountItem1;
        Account accountItem2;
        User userTest;
        User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
        System.runAs(thisUser) {
            List<RecordType> rectCo = [
                SELECT Id
                FROM RecordType
                WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '販売店'
            ];
            if (rectCo.size() == 0) {
                return;
            }
            List<RecordType> rectHp = [
                SELECT Id
                FROM RecordType
                WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'
            ];
            if (rectHp.size() == 0) {
                return;
            }
            Profile prof = [
                SELECT Id
                FROM Profile
                WHERE Name = '901_经销商社区普通权限_2重验证(ET)'
            ];
            accountItem1 = new Account(Name = 'Testaccount001', RecordTypeId = rectCo[0].Id, AgentCode_Ext__c = '9999900');
            insert accountItem1;
            accountItem2 = new Account(Name = 'Testaccount002', RecordTypeId = rectHp[0].Id, AgentCode_Ext__c = '9999999');
            insert accountItem2;
            Contact core = new Contact(
                email = 'jplumber@salesforce.com',
                firstname = 'Joe',
                lastname = 'Plumber',
                accountId = accountItem1.Id
            );
            insert core;
            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 Id = UserInfo.getUserId();
            User thisUserInfo = [
                SELECT accountid, ContactId, Contact.AccountId, Work_Location__c
                FROM User
                WHERE id = :Id
            ];
            String accountId = thisUserInfo.Contact.AccountId;
            String userWorkLocation = thisUserInfo.Work_Location__c;
            String accountName;
            Account[] accountInfo = [
                SELECT Name
                FROM account
                WHERE id = :accountId
                LIMIT 1
            ];
            if (accountInfo.size() > 0) {
                accountName = accountInfo[0].Name;
            }

            Product2 prod01 = new Product2(
                Name = 'Test01',
                ProductCode = 'Test01',
                Asset_Model_No__c = 'Test01',
                SFDA_Status__c = '有効',
                Dealer_special_Object__c = true,
                Packing_list_manual__c = 12,
                Manual_Entry__c = false
            );
            Product2 prod02 = new Product2(
                Name = 'Test02',
                ProductCode = 'Test02',
                Asset_Model_No__c = 'Test02',
                SFDA_Status__c = '有効',
                Dealer_special_Object__c = true,
                Packing_list_manual__c = 12,
                Manual_Entry__c = false
            );
            insert new List<Product2>{ prod01, prod02 };
            Product2__c pro1 = new Product2__c(Name = 'Pro001', OT_CODE_Text__c = 'Test001', Product2__c = prod01.Id);
            Product2__c pro2 = new Product2__c(Name = 'Pro002', OT_CODE_Text__c = 'Test002', Product2__c = prod02.Id);
            insert new List<Product2__c>{ pro1, pro2 };

            Consumable_order__c Order1 = new Consumable_order__c();
            Order1.Name = 'OCM_01_001';
            Order1.Order_status__c = '批准';
            Order1.Order_type__c = '订单';
            Order1.Deliver_date__c = Date.today();
            Order1.RecordTypeid = System.Label.RT_ConOrder_Order;
            Order1.Order_ForDealerText__c = 'Test';
            Order1.Order_ProType__c = 'ENG';
            Order1.Delivery_detail_count__c = 5;
            Order1.IsShipment__c = true;
            insert Order1;
            //到货
            Consumable_order__c Order2 = new Consumable_order__c();
            Order2.Name = 'testMing2';
            Order2.Order_status__c = '批准';
            Order2.Deliver_date__c = Date.today();
            Order2.RecordTypeid = System.Label.RT_ConOrder_Arrive;
            Order2.Order_type__c = '订单';
            Order2.Order_ProType__c = 'ENG';
            Order2.Arrive_Order__c = Order1.Id;
            Order2.Delivery_detail_count__c = 5;
            insert Order2;

            List<Consumable_order_details2__c> newdet2 = new List<Consumable_order_details2__c>();
            //在库 盒
            Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
            Orderdet1.Name = 'OCM_01_001002';
            Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet1.Bar_Code__c = '11111250AAAAA';
            Orderdet1.Arrive_date__c = Date.today();
            Orderdet1.Consumable_Product__c = pro1.Id;
            Orderdet1.Box_Piece__c = '盒';
            Orderdet1.TracingCode__c = 'AAAAA';
            //未到货
            Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
            Orderdet2.Name = 'OCM_02_001002';
            Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet2.Bar_Code__c = '22222250BBBBB';
            Orderdet2.Consumable_Product__c = pro2.Id;
            Orderdet2.Box_Piece__c = '盒';
            Orderdet2.TracingCode__c = 'BBBBB';
            //销售
            Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
            Orderdet3.Name = 'OCM_01_001003';
            Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet3.Bar_Code__c = '33333250CCCCC';
            Orderdet3.Consumable_Product__c = pro1.Id;
            Orderdet3.Used_date__c = Date.today();
            Orderdet3.Send_Date__c = Date.today();
            Orderdet3.Arrive_date__c = Date.today();
            Orderdet3.Box_Piece__c = '盒';
            Orderdet3.TracingCode__c = 'CCCCC';

            //在库 个
            Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
            Orderdet4.Name = 'OCM_01_001004';
            Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet4.Bar_Code__c = '44444250DDDDD';
            Orderdet4.Consumable_Product__c = pro1.Id;
            Orderdet4.Arrive_date__c = Date.today();
            Orderdet4.Box_Piece__c = '个';
            Orderdet4.TracingCode__c = 'DDDDD';

            Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
            Orderdet5.Name = 'OCM_01_001004';
            Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet5.Bar_Code__c = '55555250EEEEE';
            Orderdet5.Consumable_Product__c = pro1.Id;
            Orderdet5.Arrive_date__c = Date.today();
            Orderdet5.TracingCode__c = 'EEEEE';
            insert new List<Consumable_order_details2__c>{ Orderdet1, Orderdet2, Orderdet3, Orderdet4, Orderdet5 };

            Consumable_order__c zsd01 = new Consumable_order__c();
            zsd01.Name = 'ZSD_01_001';
            zsd01.Order_type__c = '传票';
            zsd01.SummonsStatus_c__c = '已完成';
            zsd01.Order_type__c = '订单';
            zsd01.RecordTypeid = System.Label.RT_ConOrder_Order;
            zsd01.Summons_Sale_Status__c = '销售';
            zsd01.Outbound_Date__c = Date.today();
            zsd01.IsShipment__c = true;
            insert zsd01;
            System.debug('zsd01:' + zsd01.Id);

            List<Consumable_orderdetails__c> orderdetails = new List<Consumable_orderdetails__c>();
            Consumable_orderdetails__c Orderdet6 = new Consumable_orderdetails__c();
            Orderdet6.Name = 'ZSD_01_001001';
            Orderdet6.Consumable_order__c = zsd01.Id;
            Orderdet6.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
            Orderdet6.Consumable_Count__c = 12;
            Orderdet6.Consumable_Product__c = pro1.Id;
            Orderdet6.Delivery_List_RMB__c = 1;
            Orderdet6.Shipment_Count__c = 1;
            Orderdet6.Unitprice_To_agency__c = 1.00;
            Orderdet6.Dealer_Custom_Price__c = 999.00;
            Orderdet6.isOutPattern__c = true;
            Orderdet6.Box_Piece__c = '个';
            orderdetails.add(Orderdet6);
            Consumable_orderdetails__c Orderdetc6 = new Consumable_orderdetails__c();
            Orderdetc6.Name = 'ZSD_01_001001';
            Orderdetc6.Consumable_order__c = zsd01.Id;
            Orderdetc6.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
            Orderdetc6.Consumable_Count__c = 12;
            Orderdetc6.Consumable_Product__c = pro2.Id;
            Orderdetc6.Delivery_List_RMB__c = 1;
            Orderdetc6.Unitprice_To_agency__c = 1.00;
            Orderdetc6.Dealer_Custom_Price__c = 999.00;
            Orderdetc6.Shipment_Count__c = 1;
            Orderdetc6.isOutPattern__c = true;
            Orderdetc6.Box_Piece__c = '盒';
            orderdetails.add(Orderdetc6);
            insert orderdetails;
            System.debug('orderdetails:' + orderdetails.size());

            hospitalprice__c hp1 = new hospitalprice__c();
            hp1.hospital__c = accountId;
            hp1.account__c = accountId;
            hp1.product__c = pro1.Id;
            insert hp1;

            orderpieceorboxMap = new Map<String, String>();
            orderagencypriceMap = new Map<String, Decimal>();
            orderpriceMap = new Map<String, Decimal>();
            orderdetCountMap = new Map<String, Decimal>();
            if (orderdetails.size() > 0) {
                for (Integer i = 0; i < orderdetails.size(); i++) {
                    orderpieceorboxMap.put(orderdetails[i].Product_Pattern__c, orderdetails[i].Box_Piece__c);
                    if (orderdetails[i].Unitprice_To_agency__c != null && orderdetails[i].Unitprice_To_agency__c != 0) {
                        orderagencypriceMap.put(orderdetails[i].Product_Pattern__c, orderdetails[i].Unitprice_To_agency__c);
                    }
                    orderpriceMap.put(orderdetails[i].Product_Pattern__c, orderdetails[i].Delivery_List_RMB__c);
                    orderdetCountMap.put(orderdetails[i].Product_Pattern__c, orderdetails[i].Shipment_Count__c);
                }
            }
            String ESetId = Order2.Id;
            System.Test.startTest();
            LexSaleOrderController.GoodsDeliveryInit(ESetId);
            String barcode1 = '';
            String key = '';
            String baseUrl = '';
            Integer a = 0;
            List<LexSaleOrderController.ConsumableorderdetailsInfo> consumableorderdetailsRecords = new List<LexSaleOrderController.ConsumableorderdetailsInfo>();
            Map<String, Integer> msiMap = new Map<String, Integer>();
            LexSaleOrderController.SearchPro(Order1, barcode1, accountName, userWorkLocation, accountId, orderdetails, orderpieceorboxMap);
            String barcode = '11111250AAAAA\n22222250BBBBB\n33333250CCCCC\n44444250DDDDD\n55555250EEEEE\n666666\n777777\naaa';
            LexSaleOrderController.ParseBarCode(barcode);
            LexSaleOrderController.SearchPro(Order2, barcode, accountName, userWorkLocation, accountId, orderdetails, orderpieceorboxMap);
            LexSaleOrderController.ProdElivery(
                ESetId,
                Order2,
                barcode,
                accountName,
                userWorkLocation,
                JSON.serialize(consumableorderdetailsRecords),
                orderdetails,
                orderpriceMap,
                orderagencypriceMap
            );
            LexSaleOrderController.ProSale(
                ESetId,
                Order2,
                barcode,
                accountName,
                userWorkLocation,
                JSON.serialize(consumableorderdetailsRecords),
                orderdetails,
                orderpriceMap,
                orderagencypriceMap
            );
            LexSaleOrderController.Getconsumableorderdetails2Nobox();

            List<LexSaleOrderController.ConsumableorderdetailsInfo> inList = LexSaleOrderController.consumableorderdetailsRecords;
            List<LexSaleOrderController.ConsumableorderdetailsInfo> inList1 = new List<LexSaleOrderController.ConsumableorderdetailsInfo>();
            for (LexSaleOrderController.ConsumableorderdetailsInfo ass : inList) {
                ass.orderdetails2 = Orderdet1;
                inList1.add(ass);
            }

            String errorReason = 'success';
            LexSaleOrderController.ConsumableorderdetailsInfo c2 = new LexSaleOrderController.ConsumableorderdetailsInfo(
                Orderdet1,
                errorReason
            );
=======
    static void testInit(){
        Account accountItem1;
        Account accountItem2;
        User userTest;
        User thisUser = [SELECT Id FROM User WHERE Id =:UserInfo.getUserId()];
        System.runAs(thisUser){
            List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = true AND SobjectType = 'Account' AND Name = '販売店'];
            if (rectCo.size() == 0) {
                return;
            }
            List<RecordType> rectHp = [SELECT Id FROM RecordType WHERE IsActive = true AND SobjectType = 'Account' AND Name = '病院'];
            if (rectHp.size() == 0) {
                return;
            }
            Profile prof = [SELECT Id FROM Profile WHERE Name ='901_经销商社区普通权限_2重验证(ET)'];
            accountItem1 = new Account(Name='Testaccount001',RecordTypeId = rectCo[0].Id, AgentCode_Ext__c = '9999900');
            insert accountItem1;
            accountItem2 = new Account(Name='Testaccount002',RecordTypeId = rectHp[0].Id, AgentCode_Ext__c = '9999999');
            insert accountItem2;
            Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe', lastname='Plumber', accountId = accountItem1.Id);
            insert core;
            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 Id = UserInfo.getUserId();
            User thisUserInfo = [SELECT accountid,ContactId,Contact.AccountId, Work_Location__c FROM User WHERE id =:Id];
            String accountId = thisUserInfo.Contact.AccountId;
            String userWorkLocation = thisUserInfo.Work_Location__c;
            String accountName;
            Account[] accountInfo = [SELECT Name FROM account WHERE id = :accountId LIMIT 1];
            if(accountInfo.size() > 0 ){
                accountName = accountInfo[0].Name;
            }

            Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c=12,Manual_Entry__c = false);
            Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c=12,Manual_Entry__c = false);
            insert new Product2[]{prod01,prod02};
            Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
            Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
            insert new Product2__c[] {pro1, pro2};
            
            Consumable_order__c Order1 = new Consumable_order__c();
            Order1.Name = 'OCM_01_001';
            Order1.Order_status__c = '批准';
            Order1.Order_type__c = '订单';
            Order1.Deliver_date__c = Date.today();
            Order1.RecordTypeid = System.Label.RT_ConOrder_Order;
            Order1.Order_ForDealerText__c = 'Test';
            Order1.Order_ProType__c = 'ENG';
            Order1.Delivery_detail_count__c = 5;
            Order1.IsShipment__c = true;
            insert  Order1;
            //到货
            Consumable_order__c Order2 = new Consumable_order__c();
            Order2.Name = 'testMing2';
            Order2.Order_status__c = '批准';
            Order2.Deliver_date__c = Date.today();
            Order2.RecordTypeid = System.Label.RT_ConOrder_Arrive;
            Order2.Order_type__c = '订单';
            Order2.Order_ProType__c = 'ENG';
            Order2.Arrive_Order__c = Order1.Id;
            Order2.Delivery_detail_count__c = 5;
            insert Order2;

            List<Consumable_order_details2__c> newdet2 = new List<Consumable_order_details2__c>();
            //在库 盒
            Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
            Orderdet1.Name = 'OCM_01_001002';
            Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet1.Bar_Code__c = '11111250AAAAA';
            Orderdet1.Arrive_date__c = Date.today();
            Orderdet1.Consumable_Product__c = pro1.Id;
            Orderdet1.Box_Piece__c = '盒';
            Orderdet1.TracingCode__c = 'AAAAA';
            //未到货
            Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
            Orderdet2.Name = 'OCM_02_001002';
            Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet2.Bar_Code__c = '22222250BBBBB';
            Orderdet2.Consumable_Product__c = pro2.Id;
            Orderdet2.Box_Piece__c = '盒';
            Orderdet2.TracingCode__c = 'BBBBB';
            //销售
            Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
            Orderdet3.Name = 'OCM_01_001003';
            Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet3.Bar_Code__c = '33333250CCCCC';
            Orderdet3.Consumable_Product__c = pro1.Id;
            Orderdet3.Used_date__c = Date.today();
            Orderdet3.Send_Date__c = Date.today();
            Orderdet3.Arrive_date__c = Date.today();
            Orderdet3.Box_Piece__c = '盒';
            Orderdet3.TracingCode__c = 'CCCCC';

            //在库 个
            Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
            Orderdet4.Name = 'OCM_01_001004';
            Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery ;
            Orderdet4.Bar_Code__c = '44444250DDDDD';
            Orderdet4.Consumable_Product__c = pro1.Id;
            Orderdet4.Arrive_date__c = Date.today();
            Orderdet4.Box_Piece__c = '个';
            Orderdet4.TracingCode__c = 'DDDDD';

            Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
            Orderdet5.Name = 'OCM_01_001004';
            Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery ;
            Orderdet5.Bar_Code__c = '55555250EEEEE';
            Orderdet5.Consumable_Product__c = pro1.Id;
            Orderdet5.Arrive_date__c = Date.today();
            Orderdet5.TracingCode__c = 'EEEEE';
            insert new Consumable_order_details2__c[] {Orderdet1,Orderdet2,Orderdet3,Orderdet4,Orderdet5};

            Consumable_order__c zsd01 = new Consumable_order__c();
            zsd01.Name = 'ZSD_01_001';
            zsd01.Order_type__c = '传票';
            zsd01.SummonsStatus_c__c ='已完成';
            zsd01.Order_type__c = '订单';
            zsd01.RecordTypeid = System.Label.RT_ConOrder_Order;
            zsd01.Summons_Sale_Status__c = '销售';
            zsd01.Outbound_Date__c = Date.today();
            zsd01.IsShipment__c = true;
            insert zsd01;
            System.debug('zsd01:' + zsd01.Id);

            List<Consumable_orderdetails__c> orderdetails = new List<Consumable_orderdetails__c>();
            Consumable_orderdetails__c Orderdet6 = new Consumable_orderdetails__c();
            Orderdet6.Name = 'ZSD_01_001001';
            Orderdet6.Consumable_order__c = zsd01.Id;
            Orderdet6.RecordTypeId = System.Label.RT_ConOrderDetail1_Order  ;
            Orderdet6.Consumable_Count__c = 12;
            Orderdet6.Consumable_Product__c = pro1.Id;
            Orderdet6.Delivery_List_RMB__c = 1;
            Orderdet6.Shipment_Count__c = 1;
            Orderdet6.Unitprice_To_agency__c = 1.00;
            Orderdet6.Dealer_Custom_Price__c = 999.00;
            Orderdet6.isOutPattern__c = true;
            Orderdet6.Box_Piece__c = '个';
            orderdetails.add(Orderdet6);
            Consumable_orderdetails__c Orderdetc6 = new Consumable_orderdetails__c();
            Orderdetc6.Name = 'ZSD_01_001001';
            Orderdetc6.Consumable_order__c = zsd01.Id;
            Orderdetc6.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
            Orderdetc6.Consumable_Count__c = 12;
            Orderdetc6.Consumable_Product__c = pro2.Id;
            Orderdetc6.Delivery_List_RMB__c = 1;
            Orderdetc6.Unitprice_To_agency__c = 1.00;
            Orderdetc6.Dealer_Custom_Price__c = 999.00;
            Orderdetc6.Shipment_Count__c = 1;
            Orderdetc6.isOutPattern__c = true;
            Orderdetc6.Box_Piece__c = '盒';
            orderdetails.add(Orderdetc6);
            insert orderdetails;
            System.debug('orderdetails:' + orderdetails.size());

            hospitalprice__c hp1 = new hospitalprice__c();
            hp1.hospital__c = accountId;
            hp1.account__c = accountId;
            hp1.product__c = pro1.Id;
            insert hp1;

            orderpieceorboxMap = new Map<String, String>();
            orderagencypriceMap = new Map<String, Decimal>();
            orderpriceMap = new Map<String, Decimal>();
            orderdetCountMap = new Map<String, Decimal>();
            if(orderdetails.size() > 0 ){
                for (Integer i = 0; i < orderdetails.size(); i++) {
                    orderpieceorboxMap.put(orderdetails[i].Product_Pattern__c, orderdetails[i].Box_Piece__c);
                    if (orderdetails[i].Unitprice_To_agency__c != null && orderdetails[i].Unitprice_To_agency__c != 0) {
                        orderagencypriceMap.put(orderdetails[i].Product_Pattern__c, orderdetails[i].Unitprice_To_agency__c);
                    }
                    orderpriceMap.put(orderdetails[i].Product_Pattern__c, orderdetails[i].Delivery_List_RMB__c);
                    orderdetCountMap.put(orderdetails[i].Product_Pattern__c, orderdetails[i].Shipment_Count__c);
                }
            }
            String ESetId = Order2.Id;
            System.Test.startTest();
            LexSaleOrderController.GoodsDeliveryInit(ESetId);
            String barcode1 = '';
            String key = '';
            String baseUrl = '';
            Integer a = 0;
            List<LexSaleOrderController.ConsumableorderdetailsInfo> consumableorderdetailsRecords = new List<LexSaleOrderController.ConsumableorderdetailsInfo>();
            Map<String, Integer> msiMap = new Map<String, Integer>();
            LexSaleOrderController.SearchPro(Order1,barcode1,accountName,userWorkLocation,accountId,orderdetails,orderpieceorboxMap);
            String barcode = '11111250AAAAA\n22222250BBBBB\n33333250CCCCC\n44444250DDDDD\n55555250EEEEE\n666666\n777777\naaa';
            LexSaleOrderController.ParseBarCode(barcode);
            LexSaleOrderController.SearchPro(Order2,barcode,accountName,userWorkLocation,accountId,orderdetails,orderpieceorboxMap);
            LexSaleOrderController.ProdElivery(ESetId,Order2,barcode,accountName,userWorkLocation,JSON.serialize(consumableorderdetailsRecords),orderdetails,orderpriceMap,orderagencypriceMap);
            LexSaleOrderController.ProSale(ESetId,Order2,barcode,accountName,userWorkLocation,JSON.serialize(consumableorderdetailsRecords),orderdetails,orderpriceMap,orderagencypriceMap);
            LexSaleOrderController.Getconsumableorderdetails2Nobox();

            
            List<LexSaleOrderController.ConsumableorderdetailsInfo> inList = LexSaleOrderController.consumableorderdetailsRecords;
            List<LexSaleOrderController.ConsumableorderdetailsInfo> inList1 = new List<LexSaleOrderController.ConsumableorderdetailsInfo>(); 
            for(LexSaleOrderController.ConsumableorderdetailsInfo ass: inList){
                ass.orderdetails2= Orderdet1;
                inList1.add(ass);
            }


            String errorReason = 'success';
            LexSaleOrderController.ConsumableorderdetailsInfo c2 = new LexSaleOrderController.ConsumableorderdetailsInfo(Orderdet1,errorReason);
>>>>>>> LEXCommunityLiJun
            c2.orderdetails1 = null;
            c2.orderdetails2 = Orderdet1;
            c2.Prod = Orderdet1.Consumable_product__r;
            c2.oldConsumableCount = Orderdet1.Name;
            c2.ErrorReason = errorReason;

            LexSaleOrderController.ConsumableorderdetailsInfo c1 = new LexSaleOrderController.ConsumableorderdetailsInfo(Orderdet2);
            c1.orderdetails1 = null;
            c1.orderdetails2 = Orderdet2;
            c1.Prod = Orderdet2.Consumable_product__r;
            c1.oldConsumableCount = Orderdet2.Name;
            c1.compareTo(c2);
<<<<<<< HEAD

            LexSaleOrderController.ConsumableorderdetailsInfo c3 = new LexSaleOrderController.ConsumableorderdetailsInfo(Orderdet6);
            c3.orderdetails1 = Orderdet6;
            c3.Prod = Orderdet6.Consumable_product__r;
            c3.outboundCount = Orderdet6.Shipment_Count__c;
            System.Test.stopTest();
=======
            
            LexSaleOrderController.ConsumableorderdetailsInfo c3 = new LexSaleOrderController.ConsumableorderdetailsInfo(Orderdet6);
            c3.orderdetails1 = Orderdet6;
            c3.Prod = Orderdet6.Consumable_product__r;
            c3.outboundCount = Orderdet6.Shipment_Count__c;
            System.Test.stopTest();

>>>>>>> LEXCommunityLiJun
        }
    }

    @isTest
    static void testArriveOrder() {
        StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
        Account myAccount2;
        Account olympus;
        User MyUser_Test;
<<<<<<< HEAD
        User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
        System.runAs(thisUser) {
            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 hosCo = [
                SELECT Id
                FROM RecordType
                WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'
            ];
            olympus = new Account(RecordTypeId = hosCo.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
            insert olympus;
            myAccount2 = new Account(Name = 'Testaccount002', Dealer_discount__c = 20, RecordTypeId = rectCo[0].Id);
            insert myAccount2;
            Contact core = new Contact(
                email = 'jplumber@salesforce.com',
                firstname = 'Joe',
                lastname = 'Plumber',
                accountid = myAccount2.id
            );
            insert core;
            MyUser_Test = new User(
                ContactId = core.id,
                Alias = 'newUser',
                Email = 'newuser@testorg.com',
                EmailEncodingKey = 'UTF-8',
                LastName = 'TestUser',
                LanguageLocaleKey = 'zh_CN',
                LocaleSidKey = 'zh_CN',
                ProfileId = prof.Id,
                TimeZoneSidKey = 'Asia/Shanghai',
                UserName = 'testUser@testorg.com',
                UserPro_Type__c = 'ENG',
                Work_Location__c = '大连'
            );
            insert MyUser_Test;
        }
        System.runAs(MyUser_Test) {
            String Id = UserInfo.getUserId();
            User thisUserInfo = [
                SELECT accountid, ContactId, Contact.AccountId, Work_Location__c
                FROM User
                WHERE id = :Id
            ];
=======
        User thisUser = [SELECT Id FROM User WHERE Id =:UserInfo.getUserId()];
        System.runAs(thisUser){
            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 hosCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
            olympus = new Account(RecordTypeId = hosCo.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
            insert olympus;
            myAccount2 = new Account(Name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
            insert myAccount2;
            Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount2.id);
            insert core;
            MyUser_Test = New User(ContactId = core.id, Alias = 'newUser', Email='newuser@testorg.com', EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN', LocaleSidKey='zh_CN', ProfileId = prof.Id, TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com', UserPro_Type__c='ENG', Work_Location__c='大连');
            insert MyUser_Test;
        }
        system.runAs(MyUser_Test){
            String Id = UserInfo.getUserId();
            User thisUserInfo = [SELECT accountid,ContactId,Contact.AccountId, Work_Location__c FROM User WHERE id =:Id];
>>>>>>> LEXCommunityLiJun
            String accountId = thisUserInfo.Contact.AccountId;
            String userWorkLocation1 = thisUserInfo.Work_Location__c;
            String accountName = myAccount2.Name;
            System.debug('accountName = ' + accountName);
            System.debug('userWorkLocation1 = ' + userWorkLocation1);
<<<<<<< HEAD
            Product2 prod01 = new Product2(
                Name = 'Test01',
                ProductCode = 'Test01',
                Asset_Model_No__c = 'Test01',
                SFDA_Status__c = '有効',
                Dealer_special_Object__c = true,
                Packing_list_manual__c = 12,
                Manual_Entry__c = false
            );
            Product2 prod02 = new Product2(
                Name = 'Test02',
                ProductCode = 'Test02',
                Asset_Model_No__c = 'Test02',
                SFDA_Status__c = '有効',
                Dealer_special_Object__c = true,
                Packing_list_manual__c = 12,
                Manual_Entry__c = false
            );
            insert new List<Product2>{ prod01, prod02 };
            Product2__c pro1 = new Product2__c(Name = 'Pro001', OT_CODE_Text__c = 'Test001', Product2__c = prod01.Id);
            Product2__c pro2 = new Product2__c(Name = 'Pro002', OT_CODE_Text__c = 'Test002', Product2__c = prod02.Id);
            insert new List<Product2__c>{ pro1, pro2 };
=======
            Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c=12,Manual_Entry__c = false);
            Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c=12,Manual_Entry__c = false);
            insert new Product2[]{prod01,prod02};
            Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
            Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
            insert new Product2__c[] {pro1, pro2};
>>>>>>> LEXCommunityLiJun

            Consumable_order__c Order1 = new Consumable_order__c();
            Order1.Name = 'OCM_01_001';
            Order1.Order_status__c = '批准';
            Order1.Order_type__c = '订单';
            Order1.RecordTypeid = System.Label.RT_ConOrder_Order;
<<<<<<< HEAD
            Order1.IsShipment__c = true;
=======
            Order1.IsShipment__c = True;
>>>>>>> LEXCommunityLiJun
            Order1.OwnerId = MyUser_Test.Id;
            insert Order1;

            Consumable_order__c Order2 = new Consumable_order__c();
            Order2.Name = 'OCM_02_001';
            Order2.Order_status__c = '批准';
            Order2.Order_type__c = '订单';
            Order2.RecordTypeid = System.Label.RT_ConOrder_Order;
            Order2.Dealer_Info__c = myAccount2.Id;
<<<<<<< HEAD
            Order2.IsShipment__c = true;
            insert Order2;

            Consumable_order__c Order3 = new Consumable_order__c();
            Order3.Name = 'OCM_02_005';
            Order3.Order_status__c = '批准';
            Order3.Order_type__c = '传票';
            Order3.RecordTypeid = System.Label.RT_ConOrder_Order;
            Order3.Arrive_Order__c = Order1.Id;
            Order3.Dealer_Info__c = myAccount2.Id;
            Order3.SummonsForDirction__c = '直接销售给医院';
            Order3.IsShipment__c = true;
            insert Order3;

            Consumable_order_details2__c Orderdet = new Consumable_order_details2__c();
            Orderdet.Name = 'OCM_01_001001';
            Orderdet.Consumable_Product__c = pro1.Id;
            Orderdet.Consumable_order_minor__c = Order1.Id;
            Orderdet.Consumable_Arrived_order__c = Order1.Id;
            Orderdet.Consumable_ZS_order__c = Order3.Id;
            Orderdet.Consumable_Return_order__c = Order1.Id;
            Orderdet.Consumable_Sale_order__c = null;
            Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet.RemoveBox_No__c = 3;
            Orderdet.Bar_Code__c = '1111111111250AAAAA';
            Orderdet.Arrive_date__c = Date.today();
            Orderdet.Delivery_List_RMB__c = 11.11;
            Orderdet.Box_Piece__c = '盒';
            Orderdet.Return_date__c = null;
            Orderdet.TracingCode__c = '';
            Orderdet.Cancellation_Flag__c = true;
            Orderdet.Sterilization_limit__c = Date.today().addDays(-1);
            //发货
            Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
            Orderdet1.Name = 'OCM_01_001001';
            Orderdet1.Consumable_Product__c = pro1.Id;
            Orderdet1.Consumable_order_minor__c = Order1.Id;
            Orderdet1.Consumable_ZS_order__c = Order3.Id;
            Orderdet1.Consumable_Return_order__c = Order1.Id;
            Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet1.RemoveBox_No__c = 3;
            Orderdet1.Bar_Code__c = '2222222222250BBBBB';
            Orderdet1.Arrive_date__c = Date.today();
            Orderdet1.Return_reason__c = null;
            Orderdet1.Return_date__c = null;
            Orderdet1.Delivery_List_RMB__c = 11.11;
            Orderdet1.Box_Piece__c = '个';
            Orderdet1.TracingCode__c = '';
            Orderdet1.Cancellation_Flag__c = true;
            Orderdet1.Sterilization_limit__c = Date.today().addDays(-1);
            //销售
            Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
            Orderdet2.Name = 'OCM_01_001002';
            Orderdet2.Consumable_order_minor__c = Order3.Id;
            Orderdet2.Consumable_Shipment_order__c = Order3.Id;
            Orderdet2.Consumable_Sale_order__c = Order3.Id;
            Orderdet2.Consumable_ZS_order__c = Order3.Id;
            Orderdet2.Consumable_Return_order__c = Order3.Id;
            Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet2.RemoveBox_No__c = 3;
            Orderdet2.Bar_Code__c = '3333333333250CCCCC';
            Orderdet2.Consumable_Product__c = pro1.Id;
            Orderdet2.Send_Date__c = null;
            Orderdet2.Used_date__c = null;
            Orderdet2.Lose_Flag__c = false;
            Orderdet2.Return_reason__c = null;
            Orderdet2.Return_date__c = null;
            Orderdet2.Delivery_List_RMB__c = 11;
            Orderdet2.Box_Piece__c = '盒';
            Orderdet2.TracingCode__c = null;
            Orderdet2.Cancellation_Flag__c = true;
            Orderdet2.Arrive_date__c = Date.today();
            Orderdet2.Sterilization_limit__c = Date.today().addDays(-1);
            //销售
            Consumable_order_details2__c Orderdet9 = new Consumable_order_details2__c();
            Orderdet9.Name = 'OCM_01_001002';
            Orderdet9.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet9.RemoveBox_No__c = 3;
            Orderdet9.Bar_Code__c = '4444444444250DDDDD';
            Orderdet9.Consumable_Product__c = pro1.Id;
            Orderdet9.Arrive_date__c = Date.today();
            Orderdet9.Used_date__c = Date.today();
            Orderdet9.Box_Piece__c = '个';
            Orderdet9.TracingCode__c = 'DDDDD';
            //出库
            Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
            Orderdet3.Name = 'OCM_01_001003';
            Orderdet3.Consumable_order_minor__c = Order1.Id;
            Orderdet3.Consumable_Shipment_order__c = Order1.Id;
            Orderdet3.Consumable_Sale_order__c = null;
            Orderdet3.Consumable_ZS_order__c = Order1.Id;
            Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet3.Bar_Code__c = '5555555555250EEEEE';
            Orderdet3.Consumable_Product__c = pro1.Id;
            Orderdet3.Send_Date__c = Date.today();
            Orderdet3.Box_Piece__c = '盒';
            Orderdet3.Return_date__c = null;
            Orderdet3.Lose_Flag__c = true;
            Orderdet3.TracingCode__c = 'EEEEE';

=======
            Order2.IsShipment__c = True;
            insert Order2;
       
            Consumable_order__c Order3 = new Consumable_order__c();
            Order3.Name = 'OCM_02_005';
            Order3.Order_status__c = '批准';
            Order3.Order_type__c = '传票';
            Order3.RecordTypeid = System.Label.RT_ConOrder_Order;
            Order3.Arrive_Order__c= Order1.Id; 
            Order3.Dealer_Info__c = myAccount2.Id;
            Order3.SummonsForDirction__c ='直接销售给医院';
            Order3.IsShipment__c = True;
            insert Order3;

            Consumable_order_details2__c Orderdet = new Consumable_order_details2__c();
            Orderdet.Name = 'OCM_01_001001';
            Orderdet.Consumable_Product__c = pro1.Id;
            Orderdet.Consumable_order_minor__c = Order1.Id;
            Orderdet.Consumable_Arrived_order__c = Order1.Id;
            Orderdet.Consumable_ZS_order__c = Order3.Id;
            Orderdet.Consumable_Return_order__c = Order1.Id;
            Orderdet.Consumable_Sale_order__c =null;
            Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet.RemoveBox_No__c = 3;
            Orderdet.Bar_Code__c = '1111111111250AAAAA';
            Orderdet.Arrive_date__c = Date.today();
            Orderdet.Delivery_List_RMB__c = 11.11;
            Orderdet.Box_Piece__c = '盒';
            Orderdet.Return_date__c = null;
            Orderdet.TracingCode__c = '';
            Orderdet.Cancellation_Flag__c = TRUE;
            Orderdet.Sterilization_limit__c  = Date.today().addDays(-1);
            //发货
            Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
            Orderdet1.Name = 'OCM_01_001001';
            Orderdet1.Consumable_Product__c = pro1.Id;
            Orderdet1.Consumable_order_minor__c = Order1.Id;
            Orderdet1.Consumable_ZS_order__c = Order3.Id;
            Orderdet1.Consumable_Return_order__c = Order1.Id;
            Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet1.RemoveBox_No__c = 3;
            Orderdet1.Bar_Code__c = '2222222222250BBBBB';
            Orderdet1.Arrive_date__c = Date.today();
            Orderdet1.Return_reason__c = null;
            Orderdet1.Return_date__c = null;
            Orderdet1.Delivery_List_RMB__c = 11.11;
            Orderdet1.Box_Piece__c = '个';
            Orderdet1.TracingCode__c = '';
            Orderdet1.Cancellation_Flag__c = TRUE;
            Orderdet1.Sterilization_limit__c  = Date.today().addDays(-1);
            //销售
            Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
            Orderdet2.Name = 'OCM_01_001002';
            Orderdet2.Consumable_order_minor__c = Order3.Id;
            Orderdet2.Consumable_Shipment_order__c = Order3.Id;
            Orderdet2.Consumable_Sale_order__c = Order3.Id;
            Orderdet2.Consumable_ZS_order__c = Order3.Id;
            Orderdet2.Consumable_Return_order__c = Order3.Id;
            Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet2.RemoveBox_No__c = 3;
            Orderdet2.Bar_Code__c = '3333333333250CCCCC';
            Orderdet2.Consumable_Product__c = pro1.Id;
            Orderdet2.Send_Date__c = null;
            Orderdet2.Used_date__c = null;
            Orderdet2.Lose_Flag__c = FALSE;
            Orderdet2.Return_reason__c = null;
            Orderdet2.Return_date__c = null;
            Orderdet2.Delivery_List_RMB__c = 11;
            Orderdet2.Box_Piece__c = '盒';
            Orderdet2.TracingCode__c = null;
            Orderdet2.Cancellation_Flag__c = TRUE;
            Orderdet2.Arrive_date__c = Date.today();
            Orderdet2.Sterilization_limit__c  = Date.today().addDays(-1);
            //销售
            Consumable_order_details2__c Orderdet9 = new Consumable_order_details2__c();
            Orderdet9.Name = 'OCM_01_001002';
            Orderdet9.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet9.RemoveBox_No__c = 3;
            Orderdet9.Bar_Code__c = '4444444444250DDDDD';
            Orderdet9.Consumable_Product__c = pro1.Id;
            Orderdet9.Arrive_date__c = Date.today();
            Orderdet9.Used_date__c = Date.today();
            Orderdet9.Box_Piece__c = '个';
            Orderdet9.TracingCode__c = 'DDDDD';
            //出库
            Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
            Orderdet3.Name = 'OCM_01_001003';
            Orderdet3.Consumable_order_minor__c = Order1.Id;
            Orderdet3.Consumable_Shipment_order__c = Order1.Id;
            Orderdet3.Consumable_Sale_order__c = null;
            Orderdet3.Consumable_ZS_order__c = Order1.Id;
            Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet3.Bar_Code__c = '5555555555250EEEEE';
            Orderdet3.Consumable_Product__c = pro1.Id;
            Orderdet3.Send_Date__c = Date.today();
            Orderdet3.Box_Piece__c = '盒';
            Orderdet3.Return_date__c= null;
            Orderdet3.Lose_Flag__c = True;
            Orderdet3.TracingCode__c = 'EEEEE';

>>>>>>> LEXCommunityLiJun
            //到货
            Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
            Orderdet4.Name = 'OCM_01_001004';
            Orderdet4.Consumable_order_minor__c = null;
            Orderdet4.Consumable_Sale_order__c = null;
            Orderdet4.Consumable_ZS_order__c = Order1.Id;
<<<<<<< HEAD
            Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
=======
            Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery ;
>>>>>>> LEXCommunityLiJun
            Orderdet4.Consumable_Arrived_order__c = Order1.Id;
            Orderdet4.Sterilization_limit__c = Date.today().addDays(-1);
            Orderdet4.Bar_Code__c = '6666666666250FFFFF';
            Orderdet4.Consumable_Product__c = pro1.Id;
            Orderdet4.Arrive_date__c = Date.today();
            Orderdet4.Box_Piece__c = '个';
            Orderdet4.TracingCode__c = 'FFFFF';
            //发货
            Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
            Orderdet5.Name = 'OCM_02_001001';
            Orderdet5.Consumable_order_minor__c = Order2.Id;
            Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet5.Bar_Code__c = '7777777777250GGGGG';
            Orderdet5.Consumable_Product__c = pro1.Id;
            Orderdet5.Deliver_date__c = Date.today();
            Orderdet5.RemoveBox_No__c = 3;
            Orderdet5.Box_Piece__c = '盒';
            Orderdet5.TracingCode__c = 'GGGGG';

            Consumable_order_details2__c Orderdet6 = new Consumable_order_details2__c();
            Orderdet6.Name = 'OCM_02_001001';
            Orderdet6.Consumable_order_minor__c = Order2.Id;
            Orderdet6.Consumable_ZS_order__c = Order2.Id;
            Orderdet6.Consumable_Return_order__c = Order2.Id;
            Orderdet6.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet6.Bar_Code__c = '8888888888250HHHHH';
            Orderdet6.Consumable_Product__c = pro1.Id;
            Orderdet6.Arrive_date__c = Date.today();
            Orderdet6.RemoveBox_No__c = 3;
<<<<<<< HEAD
            Orderdet6.Sterilization_limit__c = Date.today().addDays(-2);
=======
            Orderdet6.Sterilization_limit__c  = Date.today().addDays(-2);
>>>>>>> LEXCommunityLiJun
            Orderdet6.TracingCode__c = 'HHHHH';

            hospitalprice__c hp1 = new hospitalprice__c();
            hp1.hospital__c = accountId;
            hp1.account__c = accountId;
            hp1.product__c = pro1.Id;
            insert hp1;
<<<<<<< HEAD

            List<Consumable_order_details2__c> newdet2 = new List<Consumable_order_details2__c>();
            newdet2.add(Orderdet);
            insert newdet2;
            insert new List<Consumable_order_details2__c>{ Orderdet1, Orderdet2, Orderdet3, Orderdet4, Orderdet5, Orderdet6, Orderdet9 };

            List<Consumable_order_details2__c> cod2 = [
                SELECT Id, Arrive_Owner_Work_Location__c
                FROM Consumable_order_details2__c
                WHERE Id = :Orderdet.Id
            ];
=======
            
            List<Consumable_order_details2__c> newdet2 = new List<Consumable_order_details2__c>();
            newdet2.add(Orderdet);
            insert newdet2;
            insert new Consumable_order_details2__c[] {Orderdet1,Orderdet2,Orderdet3,Orderdet4,Orderdet5,Orderdet6,Orderdet9};

            List<Consumable_order_details2__c> cod2 =  [SELECT Id,Arrive_Owner_Work_Location__c
                                                          FROM Consumable_order_details2__c
                                                         WHERE Id =: Orderdet.Id];
>>>>>>> LEXCommunityLiJun
            System.debug('cod2:' + cod2);
            String userWorkLocation = cod2[0].Arrive_Owner_Work_Location__c;
            System.debug('userWorkLocation:' + userWorkLocation);

            Map<String, object> data = new Map<String, object>();
            String ESetId = Order2.Id;
            System.Test.startTest();
            LexSaleOrderController.GoodsDeliveryInit(ESetId);
            String barcode1 = '';
            String key = '';
            orderpieceorboxMap = new Map<String, String>();
            List<Consumable_orderdetails__c> orderdetails = new List<Consumable_orderdetails__c>();
<<<<<<< HEAD
            LexSaleOrderController.SearchPro(Order1, barcode1, accountName, userWorkLocation, accountId, orderdetails, orderpieceorboxMap);
            String barcode = '1111111111250AAAAA\n2222222222250BBBBB\n3333333333250CCCCC\n4444444444250DDDDD\n5555555555250EEEEE\n6666666666250FFFFF\n7777777777250GGGGG\n8888888888250HHHHH';
            LexSaleOrderController.SearchPro(Order2, barcode, accountName, userWorkLocation, accountId, orderdetails, orderpieceorboxMap);
            String barcode2 = '111111111250AAAAA';
            LexSaleOrderController.SearchPro(Order2, barcode2, accountName, userWorkLocation, accountId, orderdetails, orderpieceorboxMap);
            LexSaleOrderController.ProdElivery(
                ESetId,
                Order2,
                barcode2,
                accountName,
                userWorkLocation,
                JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords),
                orderdetails,
                orderpriceMap,
                orderagencypriceMap
            );
            LexSaleOrderController.ProSale(
                ESetId,
                Order2,
                barcode2,
                accountName,
                userWorkLocation,
                JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords),
                orderdetails,
                orderpriceMap,
                orderagencypriceMap
            );
            String barcode3 = '3333333333250CCCCC';
            LexSaleOrderController.SearchPro(Order3, barcode3, accountName, userWorkLocation, accountId, orderdetails, orderpieceorboxMap);
            LexSaleOrderController.ProdElivery(
                ESetId,
                Order3,
                barcode3,
                accountName,
                userWorkLocation,
                JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords),
                orderdetails,
                orderpriceMap,
                orderagencypriceMap
            );
            LexSaleOrderController.ProSale(
                ESetId,
                Order3,
                barcode3,
                accountName,
                userWorkLocation,
                JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords),
                orderdetails,
                orderpriceMap,
                orderagencypriceMap
            );
            LexSaleOrderController.Getconsumableorderdetails2Nobox();

            List<LexSaleOrderController.ConsumableorderdetailsInfo> inList = LexSaleOrderController.consumableorderdetailsRecords;
            List<LexSaleOrderController.ConsumableorderdetailsInfo> inList1 = new List<LexSaleOrderController.ConsumableorderdetailsInfo>();
            for (LexSaleOrderController.ConsumableorderdetailsInfo ass : inList) {
                ass.orderdetails2 = Orderdet1;
                inList1.add(ass);
            }

            String errorReason = 'success';
            LexSaleOrderController.ConsumableorderdetailsInfo c2 = new LexSaleOrderController.ConsumableorderdetailsInfo(
                Orderdet1,
                errorReason
            );
=======
            LexSaleOrderController.SearchPro(Order1,barcode1,accountName,userWorkLocation,accountId,orderdetails,orderpieceorboxMap);
            String barcode = '1111111111250AAAAA\n2222222222250BBBBB\n3333333333250CCCCC\n4444444444250DDDDD\n5555555555250EEEEE\n6666666666250FFFFF\n7777777777250GGGGG\n8888888888250HHHHH';
            LexSaleOrderController.SearchPro(Order2,barcode,accountName,userWorkLocation,accountId,orderdetails,orderpieceorboxMap);
            String barcode2 = '111111111250AAAAA';
            LexSaleOrderController.SearchPro(Order2,barcode2,accountName,userWorkLocation,accountId,orderdetails,orderpieceorboxMap);
            LexSaleOrderController.ProdElivery(ESetId,Order2,barcode2,accountName,userWorkLocation,JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords),orderdetails,orderpriceMap,orderagencypriceMap);
            LexSaleOrderController.ProSale(ESetId,Order2,barcode2,accountName,userWorkLocation,JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords),orderdetails,orderpriceMap,orderagencypriceMap);
            String barcode3 = '3333333333250CCCCC';
            LexSaleOrderController.SearchPro(Order3,barcode3,accountName,userWorkLocation,accountId,orderdetails,orderpieceorboxMap);
            LexSaleOrderController.ProdElivery(ESetId,Order3,barcode3,accountName,userWorkLocation,JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords),orderdetails,orderpriceMap,orderagencypriceMap);
            LexSaleOrderController.ProSale(ESetId,Order3,barcode3,accountName,userWorkLocation,JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords),orderdetails,orderpriceMap,orderagencypriceMap);
            LexSaleOrderController.Getconsumableorderdetails2Nobox();
            
            List<LexSaleOrderController.ConsumableorderdetailsInfo> inList = LexSaleOrderController.consumableorderdetailsRecords;
            List<LexSaleOrderController.ConsumableorderdetailsInfo> inList1 = new List<LexSaleOrderController.ConsumableorderdetailsInfo>(); 
            for(LexSaleOrderController.ConsumableorderdetailsInfo ass: inList){
                ass.orderdetails2= Orderdet1;
                inList1.add(ass);
            }


            String errorReason = 'success';
            LexSaleOrderController.ConsumableorderdetailsInfo c2 = new LexSaleOrderController.ConsumableorderdetailsInfo(Orderdet1,errorReason);
>>>>>>> LEXCommunityLiJun
            c2.orderdetails1 = null;
            c2.orderdetails2 = Orderdet1;
            c2.Prod = Orderdet1.Consumable_product__r;
            c2.oldConsumableCount = Orderdet1.Name;
            c2.ErrorReason = errorReason;

            LexSaleOrderController.ConsumableorderdetailsInfo c1 = new LexSaleOrderController.ConsumableorderdetailsInfo(Orderdet2);
            c1.orderdetails1 = null;
            c1.orderdetails2 = Orderdet2;
            c1.Prod = Orderdet2.Consumable_product__r;
            c1.oldConsumableCount = Orderdet2.Name;
            c1.compareTo(c2);
            System.Test.stopTest();
<<<<<<< HEAD
=======
        
>>>>>>> LEXCommunityLiJun
        }
    }

    @isTest
    static void testProSale() {
        StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
<<<<<<< HEAD
        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 hosCo = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'
        ];
        Account olympus = new Account(RecordTypeId = hosCo.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
        insert olympus;
        Account myAccount2 = new Account(name = 'Testaccount002', Dealer_discount__c = 20, RecordTypeId = rectCo[0].Id);
        insert myAccount2;
        Contact core = new Contact(email = 'jplumber@salesforce.com', firstname = 'Joe', lastname = 'Plumber', accountid = myAccount2.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 = 'ENG',
            Work_Location__c = '大连'
        );
        System.runAs(new User(Id = UserInfo.getUserId())) {
            insert MyUser_Test;
        }
        System.runAs(MyUser_Test) {
            String Id = UserInfo.getUserId();
            User thisUserInfo = [
                SELECT accountid, ContactId, Contact.AccountId, Work_Location__c
                FROM User
                WHERE id = :Id
            ];
            String accountId = thisUserInfo.Contact.AccountId;
            String userWorkLocation = thisUserInfo.Work_Location__c;
            String accountName;
            Account[] accountInfo = [
                SELECT Name
                FROM account
                WHERE id = :accountId
                LIMIT 1
            ];
            if (accountInfo.size() > 0) {
                accountName = accountInfo[0].Name;
            }
            Product2 prod01 = new Product2(
                Name = 'Test01',
                ProductCode = 'Test01',
                Asset_Model_No__c = 'Test01',
                SFDA_Status__c = '有効',
                Dealer_special_Object__c = true,
                Packing_list_manual__c = 12,
                Manual_Entry__c = false
            );
            Product2 prod02 = new Product2(
                Name = 'Test02',
                ProductCode = 'Test02',
                Asset_Model_No__c = 'Test02',
                SFDA_Status__c = '有効',
                Dealer_special_Object__c = true,
                Packing_list_manual__c = 12,
                Manual_Entry__c = false
            );
            insert new List<Product2>{ prod01, prod02 };
            Product2__c pro1 = new Product2__c(Name = 'Pro001', OT_CODE_Text__c = 'Test001', Product2__c = prod01.Id);
            Product2__c pro2 = new Product2__c(Name = 'Pro002', OT_CODE_Text__c = 'Test002', Product2__c = prod02.Id);
            insert new List<Product2__c>{ pro1, pro2 };
=======
        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 hosCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        Account olympus = new Account(RecordTypeId = hosCo.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
        insert olympus;
        Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
        insert myAccount2;
        Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount2.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='ENG', Work_Location__c='大连');
        System.runAs(new User(Id = UserInfo.getUserId())){
            insert MyUser_Test;
        }
        system.runAs(MyUser_Test){
            String Id = UserInfo.getUserId();
            User thisUserInfo = [SELECT accountid,ContactId,Contact.AccountId, Work_Location__c FROM User WHERE id =:Id];
            String accountId = thisUserInfo.Contact.AccountId;
            String userWorkLocation = thisUserInfo.Work_Location__c;
            String accountName;
            Account[] accountInfo = [SELECT Name FROM account WHERE id = :accountId LIMIT 1];
            if(accountInfo.size() > 0 ){
                accountName = accountInfo[0].Name;
            }
            Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c=12,Manual_Entry__c = false);
            Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c=12,Manual_Entry__c = false);
            insert new Product2[]{prod01,prod02};
            Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
            Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
            insert new Product2__c[] {pro1, pro2};
>>>>>>> LEXCommunityLiJun

            Consumable_order__c Order1 = new Consumable_order__c();
            Order1.Name = 'OCM_01_001';
            Order1.Order_status__c = '批准';
            Order1.Order_type__c = '订单';
            Order1.RecordTypeid = System.Label.RT_ConOrder_Order;
            Order1.Dealer_Info__c = myAccount2.Id;
<<<<<<< HEAD
            Order1.IsShipment__c = true;
            insert Order1;

            Consumable_order__c Order3 = new Consumable_order__c();
            Order3.Name = 'OCM_02_005';
            Order3.Order_status__c = '批准';
            Order3.Order_type__c = '传票';
            Order3.RecordTypeid = System.Label.RT_ConOrder_Order;
            Order3.Arrive_Order__c = Order1.Id;
            Order3.Dealer_Info__c = myAccount2.Id;
            Order3.SummonsForDirction__c = '直接销售给医院';
            Order3.IsShipment__c = true;
            insert Order3;

            List<Consumable_orderdetails__c> orderdetails = new List<Consumable_orderdetails__c>();
            //明细1
            Consumable_orderdetails__c conOrder1 = new Consumable_orderdetails__c();
            conOrder1.Name = 'OCM_01_001001';
            conOrder1.Consumable_order__c = Order1.Id;
            conOrder1.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
            conOrder1.Consumable_Count__c = 12;
            conOrder1.Consumable_Product__c = pro1.Id;
            conOrder1.Delivery_List_RMB__c = 1;
            conOrder1.Shipment_Count__c = 1;
            conOrder1.Box_Piece__c = '盒';

            Consumable_orderdetails__c conOrder2 = new Consumable_orderdetails__c();
            conOrder2.Name = 'OCM_01_001002';
            conOrder2.Consumable_order__c = Order1.Id;
            conOrder2.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
            conOrder2.Consumable_Count__c = 12;
            conOrder2.Consumable_Product__c = pro1.Id;
            conOrder2.Delivery_List_RMB__c = 1;
            conOrder2.Shipment_Count__c = 1;
            conOrder2.Box_Piece__c = '个';

            orderdetails.add(conOrder1);
            orderdetails.add(conOrder2);
            insert orderdetails;
            System.debug('orderdetails.size() = ' + orderdetails.size());

=======
            Order1.IsShipment__c = True;
            insert  Order1;
       
            Consumable_order__c Order3 = new Consumable_order__c();
            Order3.Name = 'OCM_02_005';
            Order3.Order_status__c = '批准';
            Order3.Order_type__c = '传票';
            Order3.RecordTypeid = System.Label.RT_ConOrder_Order;
            Order3.Arrive_Order__c = Order1.Id; 
            Order3.Dealer_Info__c = myAccount2.Id;
            Order3.SummonsForDirction__c ='直接销售给医院';
            Order3.IsShipment__c = True;
            insert Order3;
            
            List<Consumable_orderdetails__c> orderdetails = new List<Consumable_orderdetails__c>();
            //明细1
            Consumable_orderdetails__c conOrder1 = new Consumable_orderdetails__c();
            conOrder1.Name = 'OCM_01_001001';
            conOrder1.Consumable_order__c = Order1.Id;
            conOrder1.RecordTypeId = System.Label.RT_ConOrderDetail1_Order  ;
            conOrder1.Consumable_Count__c = 12;
            conOrder1.Consumable_Product__c = pro1.Id;
            conOrder1.Delivery_List_RMB__c = 1;
            conOrder1.Shipment_Count__c = 1;
            conOrder1.Box_Piece__c = '盒';

            Consumable_orderdetails__c conOrder2 = new Consumable_orderdetails__c();
            conOrder2.Name = 'OCM_01_001002';
            conOrder2.Consumable_order__c = Order1.Id;
            conOrder2.RecordTypeId = System.Label.RT_ConOrderDetail1_Order  ;
            conOrder2.Consumable_Count__c = 12;
            conOrder2.Consumable_Product__c = pro1.Id;
            conOrder2.Delivery_List_RMB__c = 1;
            conOrder2.Shipment_Count__c = 1;
            conOrder2.Box_Piece__c = '个';

            orderdetails.add(conOrder1);
            orderdetails.add(conOrder2);
            insert orderdetails;
            System.debug('orderdetails.size() = ' + orderdetails.size());

>>>>>>> LEXCommunityLiJun
            Consumable_order_details2__c Orderdet = new Consumable_order_details2__c();
            Orderdet.Name = 'OCM_01_001001';
            Orderdet.Consumable_Product__c = pro1.Id;
            Orderdet.Consumable_order_minor__c = Order1.Id;
            Orderdet.Consumable_ZS_order__c = Order3.Id;
            Orderdet.Consumable_Return_order__c = Order1.Id;
            Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet.RemoveBox_No__c = 3;
            Orderdet.Bar_Code__c = '1111111111250AAAAA';
            Orderdet.Arrive_date__c = Date.today();
            Orderdet.Delivery_List_RMB__c = 11.11;
            Orderdet.Box_Piece__c = '盒';
            Orderdet.Return_date__c = null;
            Orderdet.TracingCode__c = '';
<<<<<<< HEAD
            Orderdet.Cancellation_Flag__c = true;
            Orderdet.Sterilization_limit__c = Date.today().addDays(-1);
=======
            Orderdet.Cancellation_Flag__c = TRUE;
            Orderdet.Sterilization_limit__c  = Date.today().addDays(-1);
>>>>>>> LEXCommunityLiJun

            //发货
            Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
            Orderdet1.Name = 'OCM_01_001001';
            Orderdet1.Consumable_Product__c = pro1.Id;
            Orderdet1.Consumable_order_minor__c = Order1.Id;
            Orderdet1.Consumable_ZS_order__c = Order3.Id;
            Orderdet1.Consumable_Return_order__c = Order1.Id;
            Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet1.RemoveBox_No__c = 3;
            Orderdet1.Bar_Code__c = '2222222222250BBBBB';
            Orderdet1.Arrive_date__c = Date.today();
            Orderdet1.Return_reason__c = null;
            Orderdet1.Return_date__c = null;
            Orderdet1.Delivery_List_RMB__c = 11.11;
            Orderdet1.Box_Piece__c = '个';
            Orderdet1.TracingCode__c = '';
<<<<<<< HEAD
            Orderdet1.Cancellation_Flag__c = true;
            Orderdet1.Sterilization_limit__c = Date.today().addDays(-1);
=======
            Orderdet1.Cancellation_Flag__c = TRUE;
            Orderdet1.Sterilization_limit__c  = Date.today().addDays(-1);
>>>>>>> LEXCommunityLiJun
            //销售
            Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
            Orderdet2.Name = 'OCM_01_001002';
            Orderdet2.Consumable_order_minor__c = Order3.Id;
            Orderdet2.Consumable_Shipment_order__c = Order3.Id;
            Orderdet2.Consumable_Sale_order__c = Order3.Id;
            Orderdet2.Consumable_ZS_order__c = Order3.Id;
            Orderdet2.Consumable_Return_order__c = Order3.Id;
            Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet2.RemoveBox_No__c = 3;
            Orderdet2.Bar_Code__c = '3333333333250CCCCC';
            Orderdet2.Consumable_Product__c = pro1.Id;
            Orderdet2.Send_Date__c = null;
            Orderdet2.Used_date__c = null;
<<<<<<< HEAD
            Orderdet2.Lose_Flag__c = false;
=======
            Orderdet2.Lose_Flag__c = FALSE;
>>>>>>> LEXCommunityLiJun
            Orderdet2.Return_reason__c = null;
            Orderdet2.Return_date__c = null;
            Orderdet2.Delivery_List_RMB__c = 11;
            Orderdet2.Box_Piece__c = '盒';
            Orderdet2.TracingCode__c = null;
<<<<<<< HEAD
            Orderdet2.Cancellation_Flag__c = true;
            Orderdet2.Arrive_date__c = Date.today();
            Orderdet2.Sterilization_limit__c = Date.today().addDays(-1);
=======
            Orderdet2.Cancellation_Flag__c = TRUE;
            Orderdet2.Arrive_date__c = Date.today();
            Orderdet2.Sterilization_limit__c  = Date.today().addDays(-1);
>>>>>>> LEXCommunityLiJun
            //销售
            Consumable_order_details2__c Orderdet9 = new Consumable_order_details2__c();
            Orderdet9.Name = 'OCM_01_001002';
            Orderdet9.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet9.RemoveBox_No__c = 3;
            Orderdet9.Bar_Code__c = '4444444444250DDDDD';
            Orderdet9.Consumable_Product__c = pro1.Id;
            Orderdet9.Arrive_date__c = Date.today();
            Orderdet9.Used_date__c = Date.today();
            Orderdet9.Box_Piece__c = '个';
            Orderdet9.TracingCode__c = 'DDDDD';
            //出库
            Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
            Orderdet3.Name = 'OCM_01_001003';
            Orderdet3.Consumable_order_minor__c = Order1.Id;
            Orderdet3.Consumable_Shipment_order__c = Order1.Id;
            Orderdet3.Consumable_order_minor__c = null;
            Orderdet3.Consumable_Sale_order__c = null;
            Orderdet3.Consumable_ZS_order__c = Order1.Id;
            Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet3.Bar_Code__c = '5555555555250EEEEE';
            Orderdet3.Consumable_Product__c = pro1.Id;
            Orderdet3.Send_Date__c = Date.today();
            Orderdet3.Box_Piece__c = '盒';
<<<<<<< HEAD
            Orderdet3.Return_date__c = null;
            Orderdet3.Lose_Flag__c = true;
=======
            Orderdet3.Return_date__c= null;
            Orderdet3.Lose_Flag__c = True;
>>>>>>> LEXCommunityLiJun
            Orderdet3.TracingCode__c = 'EEEEE';

            List<Consumable_order_details2__c> newdet2 = new List<Consumable_order_details2__c>();
            newdet2.add(Orderdet);
            insert newdet2;
<<<<<<< HEAD
            insert new List<Consumable_order_details2__c>{ Orderdet1, Orderdet2, Orderdet3, Orderdet9 };
=======
            insert new Consumable_order_details2__c[] {Orderdet1,Orderdet2,Orderdet3,Orderdet9};
>>>>>>> LEXCommunityLiJun

            Map<String, object> data = new Map<String, object>();
            String ESetId = Order3.Id;
            System.Test.startTest();
            LexSaleOrderController.GoodsDeliveryInit(ESetId);
            String barcode1 = '';
            String key = '';
            Integer i = 0;
            Decimal a = 0;
            orderpieceorboxMap = new Map<String, String>();
<<<<<<< HEAD
            LexSaleOrderController.SearchPro(Order1, barcode1, accountName, userWorkLocation, accountId, orderdetails, orderpieceorboxMap);
            String barcode = '1111111111250AAAAA\n2222222222250BBBBB\n3333333333250CCCCC\n4444444444250DDDDD\n5555555555250EEEEE';
            LexSaleOrderController.SearchPro(Order3, barcode, accountName, userWorkLocation, accountId, orderdetails, orderpieceorboxMap);
            LexSaleOrderController.ProdElivery(
                ESetId,
                Order3,
                barcode,
                accountName,
                userWorkLocation,
                JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords),
                orderdetails,
                orderpriceMap,
                orderagencypriceMap
            );
            LexSaleOrderController.ProSale(
                ESetId,
                Order3,
                barcode,
                accountName,
                userWorkLocation,
                JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords),
                orderdetails,
                orderpriceMap,
                orderagencypriceMap
            );

            List<LexSaleOrderController.ConsumableorderdetailsInfo> inList = LexSaleOrderController.consumableorderdetailsRecords;
            List<LexSaleOrderController.ConsumableorderdetailsInfo> inList1 = new List<LexSaleOrderController.ConsumableorderdetailsInfo>();
            for (LexSaleOrderController.ConsumableorderdetailsInfo ass : inList) {
                ass.orderdetails2 = Orderdet1;
=======
            LexSaleOrderController.SearchPro(Order1,barcode1,accountName,userWorkLocation,accountId,orderdetails,orderpieceorboxMap);
            String barcode = '1111111111250AAAAA\n2222222222250BBBBB\n3333333333250CCCCC\n4444444444250DDDDD\n5555555555250EEEEE';
            LexSaleOrderController.SearchPro(Order3,barcode,accountName,userWorkLocation,accountId,orderdetails,orderpieceorboxMap);
            LexSaleOrderController.ProdElivery(ESetId,Order3,barcode,accountName,userWorkLocation,JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords),orderdetails,orderpriceMap,orderagencypriceMap);
            LexSaleOrderController.ProSale(ESetId,Order3,barcode,accountName,userWorkLocation,JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords),orderdetails,orderpriceMap,orderagencypriceMap);
            
            
            List<LexSaleOrderController.ConsumableorderdetailsInfo> inList = LexSaleOrderController.consumableorderdetailsRecords;
            List<LexSaleOrderController.ConsumableorderdetailsInfo> inList1 = new List<LexSaleOrderController.ConsumableorderdetailsInfo>(); 
            for(LexSaleOrderController.ConsumableorderdetailsInfo ass: inList){
                ass.orderdetails2= Orderdet1;
>>>>>>> LEXCommunityLiJun
                inList1.add(ass);
            }

            String errorReason = 'success';
<<<<<<< HEAD
            LexSaleOrderController.ConsumableorderdetailsInfo c2 = new LexSaleOrderController.ConsumableorderdetailsInfo(
                Orderdet1,
                errorReason
            );
=======
            LexSaleOrderController.ConsumableorderdetailsInfo c2 = new LexSaleOrderController.ConsumableorderdetailsInfo(Orderdet1,errorReason);
>>>>>>> LEXCommunityLiJun
            c2.orderdetails1 = null;
            c2.orderdetails2 = Orderdet1;
            c2.Prod = Orderdet1.Consumable_product__r;
            c2.oldConsumableCount = Orderdet1.Name;
            c2.ErrorReason = errorReason;

            LexSaleOrderController.ConsumableorderdetailsInfo c1 = new LexSaleOrderController.ConsumableorderdetailsInfo(Orderdet2);
            c1.orderdetails1 = null;
            c1.orderdetails2 = Orderdet2;
            c1.Prod = Orderdet2.Consumable_product__r;
            c1.oldConsumableCount = Orderdet2.Name;
            c1.compareTo(c2);
            System.Test.stopTest();
<<<<<<< HEAD
=======
        
>>>>>>> LEXCommunityLiJun
        }
    }

    @isTest
    static void testProdError() {
<<<<<<< HEAD
        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 hosCo = [
            SELECT Id
            FROM RecordType
            WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'
        ];
        Account olympus = new Account(RecordTypeId = hosCo.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
        insert olympus;
        Account myAccount2 = new Account(name = 'Testaccount002', Dealer_discount__c = 20, RecordTypeId = rectCo[0].Id);
        insert myAccount2;
        Contact core = new Contact(email = 'jplumber@salesforce.com', firstname = 'Joe', lastname = 'Plumber', accountid = myAccount2.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',
            Work_Location__c = '大连'
        );
        System.runAs(new User(Id = UserInfo.getUserId())) {
            insert MyUser_Test;
        }
        //订单
        System.runAs(MyUser_Test) {
            String Id = UserInfo.getUserId();
            User thisUserInfo = [
                SELECT accountid, ContactId, Contact.AccountId, Work_Location__c
                FROM User
                WHERE id = :Id
            ];
            String accountId = thisUserInfo.Contact.AccountId;
            String userWorkLocation = thisUserInfo.Work_Location__c;
            String accountName;
            Account[] accountInfo = [
                SELECT Name
                FROM account
                WHERE id = :accountId
                LIMIT 1
            ];
            if (accountInfo.size() > 0) {
                accountName = accountInfo[0].Name;
            }
            Product2 prod01 = new Product2(
                Name = 'Test01',
                ProductCode = 'Test01',
                Asset_Model_No__c = 'Test01',
                SFDA_Status__c = '有効',
                Dealer_special_Object__c = true,
                Packing_list_manual__c = 12,
                Manual_Entry__c = false
            );
            Product2 prod02 = new Product2(
                Name = 'Test02',
                ProductCode = 'Test02',
                Asset_Model_No__c = 'Test02',
                SFDA_Status__c = '有効',
                Dealer_special_Object__c = true,
                Packing_list_manual__c = 12,
                Manual_Entry__c = false
            );
            Product2 prod03 = new Product2(
                Name = 'Test03',
                ProductCode = 'Test03',
                Asset_Model_No__c = 'Test03',
                SFDA_Status__c = '有効',
                Dealer_special_Object__c = true,
                Packing_list_manual__c = 12,
                Manual_Entry__c = false
            );
            insert new List<Product2>{ prod01, prod02, prod03 };
            Product2__c pro1 = new Product2__c(Name = 'Pro001', OT_CODE_Text__c = 'Test001', Product2__c = prod01.Id);
            Product2__c pro2 = new Product2__c(Name = 'Pro002', OT_CODE_Text__c = 'Test002', Product2__c = prod02.Id);
            Product2__c pro3 = new Product2__c(Name = 'Pro003', OT_CODE_Text__c = 'Test003', Product2__c = prod03.Id);
            insert new List<Product2__c>{ pro1, pro2, pro3 };
=======
        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 hosCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        Account olympus = new Account(RecordTypeId = hosCo.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
        insert olympus;
        Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
        insert myAccount2;
        Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount2.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', Work_Location__c='大连');
        System.runAs(new User(Id = UserInfo.getUserId())){
            insert MyUser_Test;
        }
        //订单
        system.runAs(MyUser_Test){
            String Id = UserInfo.getUserId();
            User thisUserInfo = [SELECT accountid,ContactId,Contact.AccountId, Work_Location__c FROM User WHERE id =:Id];
            String accountId = thisUserInfo.Contact.AccountId;
            String userWorkLocation = thisUserInfo.Work_Location__c;
            String accountName;
            Account[] accountInfo = [SELECT Name FROM account WHERE id = :accountId LIMIT 1];
            if(accountInfo.size() > 0 ){
                accountName = accountInfo[0].Name;
            }
            Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c=12,Manual_Entry__c = false);
            Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c=12,Manual_Entry__c = false);
            Product2 prod03 = new Product2(Name='Test03',ProductCode='Test03',Asset_Model_No__c = 'Test03',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c=12,Manual_Entry__c = false);
            insert new Product2[]{prod01,prod02,prod03};
            Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
            Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
            Product2__c pro3 = new Product2__c(Name='Pro003',OT_CODE_Text__c='Test003',Product2__c = prod03.Id);
            insert new Product2__c[] {pro1, pro2,pro3};
>>>>>>> LEXCommunityLiJun
            //出库单
            Consumable_order__c Order1 = new Consumable_order__c();
            Order1.Name = 'OCM_01_001';
            Order1.Order_status__c = '批准';
            Order1.Order_type__c = '传票';
            Order1.RecordTypeid = System.Label.RT_ConOrder_Order;
            Order1.Dealer_Info__c = myAccount2.Id;
<<<<<<< HEAD
            Order1.SummonsForDirction__c = '直接销售给医院';
=======
            Order1.SummonsForDirction__c ='直接销售给医院';
>>>>>>> LEXCommunityLiJun
            Order1.IsShipment__c = true;
            insert Order1;

            List<Consumable_orderdetails__c> orderdetails = new List<Consumable_orderdetails__c>();
            //明细1
            Consumable_orderdetails__c Orderdet1 = new Consumable_orderdetails__c();
            Orderdet1.Name = 'OCM_01_001001';
            Orderdet1.Consumable_order__c = Order1.Id;
<<<<<<< HEAD
            Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
=======
            Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Order ;
>>>>>>> LEXCommunityLiJun
            Orderdet1.Consumable_Count__c = 12;
            Orderdet1.Consumable_Product__c = pro1.Id;
            Orderdet1.Unitprice_To_agency__c = 1;
            Orderdet1.Delivery_List_RMB__c = 1;
            Orderdet1.Shipment_Count__c = 1;
            Orderdet1.Box_Piece__c = '盒';
            Consumable_orderdetails__c Orderdet2 = new Consumable_orderdetails__c();
            Orderdet2.Name = 'OCM_01_001002';
            Orderdet2.Consumable_order__c = Order1.Id;
<<<<<<< HEAD
            Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
=======
            Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Order ;
>>>>>>> LEXCommunityLiJun
            Orderdet2.Consumable_Count__c = 12;
            Orderdet2.Consumable_Product__c = pro2.Id;
            Orderdet2.Unitprice_To_agency__c = 1;
            Orderdet2.Delivery_List_RMB__c = 1;
            Orderdet2.Shipment_Count__c = 1;
            Orderdet2.Box_Piece__c = '个';
            orderdetails.add(Orderdet1);
            orderdetails.add(Orderdet2);
            insert orderdetails;
<<<<<<< HEAD

            //明细2
            Consumable_order_details2__c Orderdets1 = new Consumable_order_details2__c();
            Orderdets1.Name = 'OCM_01_0010001';
            Orderdets1.Consumable_order_minor__c = Order1.Id;
            Orderdets1.Consumable_ZS_order__c = Order1.Id;
            Orderdets1.Consumable_Return_order__c = null;
            Orderdets1.Consumable_Sale_order__c = null;
            Orderdets1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdets1.Bar_Code__c = '11111250AAAAA';
            Orderdets1.Consumable_Product__c = pro1.Id;
            Orderdets1.Arrive_date__c = Date.today();
            Orderdets1.Return_date__c = null;
            Orderdets1.RemoveBox_No__c = 3;
            Orderdets1.Delivery_List_RMB__c = 11.11;
            Orderdets1.Box_Piece__c = '盒';
            Orderdets1.Sterilization_limit__c = Date.today().addDays(-1);
            Orderdets1.TracingCode__c = 'AAAAA';

            Consumable_order_details2__c Orderdets2 = new Consumable_order_details2__c();
            Orderdets2.Name = 'OCM_01_0010002';
            Orderdets2.Consumable_Return_order__c = null;
            Orderdets2.Consumable_Sale_order__c = null;
            Orderdets2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdets2.Bar_Code__c = '22222250BBBBB';
            Orderdets2.Consumable_Product__c = pro2.Id;
            Orderdets2.Arrive_date__c = Date.today();
            Orderdets2.Return_date__c = null;
            Orderdets2.RemoveBox_No__c = 3;
            Orderdets2.Delivery_List_RMB__c = 11.11;
            Orderdets2.Box_Piece__c = '个';
            Orderdets2.Sterilization_limit__c = Date.today().addDays(-1);
            Orderdets2.TracingCode__c = '';

            Consumable_order_details2__c Orderdets3 = new Consumable_order_details2__c();
            Orderdets3.Name = 'OCM_01_0010003';
            Orderdets3.Consumable_order_minor__c = Order1.Id;
            Orderdets3.Consumable_ZS_order__c = Order1.Id;
            Orderdets3.Consumable_Return_order__c = null;
            Orderdets2.Consumable_Sale_order__c = null;
            Orderdets3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdets3.Bar_Code__c = '33333250CCCCC';
            Orderdets3.Consumable_Product__c = pro3.Id;
            Orderdets3.Arrive_date__c = Date.today();
            Orderdets3.Return_date__c = null;
            Orderdets3.RemoveBox_No__c = 3;
            Orderdets3.Delivery_List_RMB__c = 11.11;
            Orderdets3.Box_Piece__c = '盒';
            Orderdets3.Sterilization_limit__c = Date.today().addDays(-1);
            Orderdets3.TracingCode__c = 'CCCCC';
            //未到货
            Consumable_order_details2__c Orderdets4 = new Consumable_order_details2__c();
            Orderdets4.Name = 'OCM_01_0010001';
            Orderdets4.Consumable_order_minor__c = Order1.Id;
            Orderdets4.Consumable_ZS_order__c = Order1.Id;
            Orderdets4.Consumable_Return_order__c = null;
            Orderdets4.Consumable_Sale_order__c = null;
            Orderdets4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdets4.Bar_Code__c = '44444250DDDDD';
            Orderdets4.Arrive_date__c = Date.today();
            Orderdets4.Return_date__c = null;
            Orderdets4.Consumable_Product__c = pro1.Id;
            Orderdets4.Delivery_List_RMB__c = 11.11;
            Orderdets4.RemoveBox_No__c = 3;
            Orderdets4.Box_Piece__c = '盒';
            Orderdets4.Sterilization_limit__c = Date.today().addDays(-1);
            Orderdets4.TracingCode__c = 'DDDDD';

            Consumable_order_details2__c Orderdets5 = new Consumable_order_details2__c();
            Orderdets5.Name = 'OCM_01_0010003';
            Orderdets5.Consumable_order_minor__c = Order1.Id;
            Orderdets5.Consumable_ZS_order__c = Order1.Id;
            Orderdets5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdets5.Bar_Code__c = '33333250EEEEE';
            Orderdets5.Consumable_Product__c = pro3.Id;
            Orderdets5.Arrive_date__c = Date.today();
            Orderdets5.Return_date__c = null;
            Orderdets5.RemoveBox_No__c = 3;
            Orderdets5.Delivery_List_RMB__c = 11.11;
            Orderdets5.Box_Piece__c = '个';
            Orderdets5.Sterilization_limit__c = Date.today().addDays(-1);
            Orderdets5.TracingCode__c = 'EEEEE';

            List<Consumable_order_details2__c> newdet2 = new List<Consumable_order_details2__c>();
            newdet2.add(Orderdets1);
            insert newdet2;
            insert new List<Consumable_order_details2__c>{ Orderdets2, Orderdets3, Orderdets4, Orderdets5 };
=======
            
            //明细2
            Consumable_order_details2__c Orderdets1 = new Consumable_order_details2__c();
            Orderdets1.Name = 'OCM_01_0010001';
            Orderdets1.Consumable_order_minor__c = Order1.Id;
            Orderdets1.Consumable_ZS_order__c = Order1.Id;
            Orderdets1.Consumable_Return_order__c = null;
            Orderdets1.Consumable_Sale_order__c =null;
            Orderdets1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdets1.Bar_Code__c = '11111250AAAAA';
            Orderdets1.Consumable_Product__c = pro1.Id;
            Orderdets1.Arrive_date__c = Date.today();
            Orderdets1.Return_date__c= null;
            Orderdets1.RemoveBox_No__c = 3;
            Orderdets1.Delivery_List_RMB__c = 11.11;
            Orderdets1.Box_Piece__c = '盒';
            Orderdets1.Sterilization_limit__c = Date.today().addDays(-1);
            Orderdets1.TracingCode__c = 'AAAAA';
            
            Consumable_order_details2__c Orderdets2 = new Consumable_order_details2__c();
            Orderdets2.Name = 'OCM_01_0010002';
            Orderdets2.Consumable_Return_order__c = null;
            Orderdets2.Consumable_Sale_order__c =null;
            Orderdets2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdets2.Bar_Code__c = '22222250BBBBB';
            Orderdets2.Consumable_Product__c = pro2.Id;
            Orderdets2.Arrive_date__c = Date.today();
            Orderdets2.Return_date__c= null;
            Orderdets2.RemoveBox_No__c = 3;
            Orderdets2.Delivery_List_RMB__c = 11.11;
            Orderdets2.Box_Piece__c = '个';
            Orderdets2.Sterilization_limit__c = Date.today().addDays(-1);
            Orderdets2.TracingCode__c = '';
            
            Consumable_order_details2__c Orderdets3 = new Consumable_order_details2__c();
            Orderdets3.Name = 'OCM_01_0010003';
            Orderdets3.Consumable_order_minor__c = Order1.Id;
            Orderdets3.Consumable_ZS_order__c = Order1.Id;
            Orderdets3.Consumable_Return_order__c = null;
            Orderdets2.Consumable_Sale_order__c =null;
            Orderdets3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdets3.Bar_Code__c = '33333250CCCCC';
            Orderdets3.Consumable_Product__c = pro3.Id;
            Orderdets3.Arrive_date__c = Date.today();
            Orderdets3.Return_date__c= null;
            Orderdets3.RemoveBox_No__c = 3;
            Orderdets3.Delivery_List_RMB__c = 11.11;
            Orderdets3.Box_Piece__c = '盒';
            Orderdets3.Sterilization_limit__c = Date.today().addDays(-1);
            Orderdets3.TracingCode__c = 'CCCCC';
            //未到货
            Consumable_order_details2__c Orderdets4 = new Consumable_order_details2__c();
            Orderdets4.Name = 'OCM_01_0010001';
            Orderdets4.Consumable_order_minor__c = Order1.Id;
            Orderdets4.Consumable_ZS_order__c = Order1.Id;
            Orderdets4.Consumable_Return_order__c = null;
            Orderdets4.Consumable_Sale_order__c =null;
            Orderdets4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdets4.Bar_Code__c = '44444250DDDDD';
            Orderdets4.Arrive_date__c = Date.today();
            Orderdets4.Return_date__c= null;
            Orderdets4.Consumable_Product__c = pro1.Id;
            Orderdets4.Delivery_List_RMB__c = 11.11;
            Orderdets4.RemoveBox_No__c = 3;
            Orderdets4.Box_Piece__c = '盒';
            Orderdets4.Sterilization_limit__c = Date.today().addDays(-1);
            Orderdets4.TracingCode__c = 'DDDDD';

            Consumable_order_details2__c Orderdets5 = new Consumable_order_details2__c();
            Orderdets5.Name = 'OCM_01_0010003';
            Orderdets5.Consumable_order_minor__c = Order1.Id;
            Orderdets5.Consumable_ZS_order__c = Order1.Id;
            Orderdets5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdets5.Bar_Code__c = '33333250EEEEE';
            Orderdets5.Consumable_Product__c = pro3.Id;
            Orderdets5.Arrive_date__c = Date.today();
            Orderdets5.Return_date__c= null;
            Orderdets5.RemoveBox_No__c = 3;
            Orderdets5.Delivery_List_RMB__c = 11.11;
            Orderdets5.Box_Piece__c = '个';
            Orderdets5.Sterilization_limit__c = Date.today().addDays(-1);
            Orderdets5.TracingCode__c = 'EEEEE';

            List<Consumable_order_details2__c> newdet2 = new List<Consumable_order_details2__c>();
            newdet2.add(Orderdets1);
            insert newdet2;
            insert new Consumable_order_details2__c[] {Orderdets2,Orderdets3,Orderdets4,Orderdets5};
>>>>>>> LEXCommunityLiJun

            List<String> barCodeListP = new List<String>();
            Map<String, object> data = new Map<String, object>();
            String ESetId = Order1.Id;
            System.Test.startTest();
            LexSaleOrderController.GoodsDeliveryInit(ESetId);
            String barcode = '11111250AAAAA\n22222250BBBBB\n33333250CCCCC\n44444250DDDDD\n33333250EEEEE';
            barCodeListP = LexSaleOrderController.ParseBarCode(barcode);
            System.debug('barCodeListP:' + barCodeListP);
            System.debug('accountName:' + accountName);
            System.debug('userWorkLocation:' + userWorkLocation);
            String key = '';
            Integer idx = 0;
            orderpieceorboxMap = new Map<String, String>();
<<<<<<< HEAD
            LexSaleOrderController.SearchPro(Order1, barcode, accountName, userWorkLocation, accountId, orderdetails, orderpieceorboxMap);
            LexSaleOrderController.ProdElivery(
                ESetId,
                Order1,
                barcode,
                accountName,
                userWorkLocation,
                JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords),
                orderdetails,
                orderpriceMap,
                orderagencypriceMap
            );
            LexSaleOrderController.ProSale(
                ESetId,
                Order1,
                barcode,
                accountName,
                userWorkLocation,
                JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords),
                orderdetails,
                orderpriceMap,
                orderagencypriceMap
            );

            System.Test.stopTest();
        }
    }

    @isTest
    static void searchTest1() {
        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)'
        ];
        Account myAccount2 = new Account(
            name = 'Testaccount002',
            Dealer_discount__c = 20,
            RecordTypeId = rectCo[0].Id,
            AgentCode_Ext__c = '9999900'
        );
        Account myAccount1 = new Account(name = 'Testaccount001', Dealer_discount__c = 30, RecordTypeId = rectCo[0].Id);
        insert new List<account>{ myAccount1, myAccount2 };
        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 };

            hospitalprice__c hp1 = new hospitalprice__c();
            hp1.hospital__c = myAccount1.Id;
            hp1.account__c = myAccount1.Id;
            hp1.product__c = pro1.Id;
            insert hp1;

            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';
            Order0.OutPattern__c = true;
            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 = 1;
            Orderdet.isOutPattern__c = true;
            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;
            insert Orderdet1;
            System.debug('Orderdet1:' + Orderdet1);
            Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
            Orderdet2.Name = 'OCM_01_001001';
            Orderdet2.Consumable_order_minor__c = Order1.Id;
            Orderdet2.Consumable_Product__c = pro1.Id;
            Orderdet2.Asset_Model_No__c = 'Test01';
            Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
            Orderdet2.Bar_Code__c = '01049531702003111115120017181234105ZK250BXJRF';
            Orderdet1.Cancellation_Date__c = null;
            Orderdet2.TracingCode__c = 'BXJRF';
            Orderdet2.SerialLotNo__c = '5ZK';
            // Orderdet2.Consumable_ZS_order__c = Order1.Id;
            // Orderdet2.Box_Piece__c = '个';
            insert Orderdet2;
            System.Test.startTest();
            String a = LexSaleOrderController.baseUrl;
            LexSaleOrderController.msiMap = new Map<String, Integer>();
            List<Consumable_orderdetails__c> orderdetails = new List<Consumable_orderdetails__c>();
            orderdetails.add(Orderdet);
            LexSaleOrderController.GoodsDeliveryInit(Order1.Id);
            String condetailList = JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords);
            Order1.Arrive_Order__c = null;
            LexSaleOrderController.SearchPro(
                Order1,
                '01049531702003111115120017181000105ZK250BXJRF',
                myAccount1.Name,
                '',
                myAccount1.Id,
                LexSaleOrderController.orderdetails,
                LexSaleOrderController.orderpieceorboxMap
            );
            LexSaleOrderController.ProdElivery(
                Order1.Id,
                LexSaleOrderController.coc,
                '01049531702003111115120017181000105ZK250BXJRF',
                myAccount1.Name,
                '',
                condetailList,
                LexSaleOrderController.orderdetails,
                LexSaleOrderController.orderpriceMap,
                LexSaleOrderController.orderagencypriceMap
            );
            LexSaleOrderController.ProSale(
                Order1.Id,
                LexSaleOrderController.coc,
                '01049531702003111115120017181000105ZK250BXJRF',
                myAccount1.Name,
                '',
                condetailList,
                LexSaleOrderController.orderdetails,
                LexSaleOrderController.orderpriceMap,
                LexSaleOrderController.orderagencypriceMap
            );
            System.Test.stopTest();
        }
    }

    @isTest
    static void searchTest2() {
        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)'
        ];
        Account myAccount2 = new Account(
            name = 'Testaccount002',
            Dealer_discount__c = 20,
            RecordTypeId = rectCo[0].Id,
            AgentCode_Ext__c = '9999900'
        );
        Account myAccount1 = new Account(name = 'Testaccount001', Dealer_discount__c = 30, RecordTypeId = rectCo[0].Id);
        insert new List<account>{ myAccount1, myAccount2 };
        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 };

            hospitalprice__c hp1 = new hospitalprice__c();
            hp1.hospital__c = myAccount1.Id;
            hp1.account__c = myAccount1.Id;
            hp1.product__c = pro1.Id;
            insert hp1;

            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';
            Order0.OutPattern__c = true;
            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 = 1;
            Orderdet.isOutPattern__c = true;
            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.debug('Orderdet1:' + Orderdet1);
            System.Test.startTest();
            String a = LexSaleOrderController.baseUrl;
            LexSaleOrderController.msiMap = new Map<String, Integer>();
            List<Consumable_orderdetails__c> orderdetails = new List<Consumable_orderdetails__c>();
            orderdetails.add(Orderdet);
            LexSaleOrderController.GoodsDeliveryInit(Order1.Id);
            LexSaleOrderController.consumableorderdetailsRecords[0].outboundCount = 1;
            String condetailList = JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords);
            LexSaleOrderController.ProdElivery(
                Order1.Id,
                LexSaleOrderController.coc,
                '01049531702003111115120017181000105ZK250BXJRF',
                myAccount1.Name,
                '',
                condetailList,
                LexSaleOrderController.orderdetails,
                LexSaleOrderController.orderpriceMap,
                LexSaleOrderController.orderagencypriceMap
            );
            // LexSaleOrderController.ProSale(Order1.Id, LexSaleOrderController.coc, '01049531702003111115120017181000105ZK250BXJRF', myAccount1.Name, '', condetailList, LexSaleOrderController.orderdetails, LexSaleOrderController.orderpriceMap, LexSaleOrderController.orderagencypriceMap);
            System.Test.stopTest();
        }
    }

    @isTest
    static void searchTest3() {
        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)'
        ];
        Account myAccount2 = new Account(
            name = 'Testaccount002',
            Dealer_discount__c = 20,
            RecordTypeId = rectCo[0].Id,
            AgentCode_Ext__c = '9999900'
        );
        Account myAccount1 = new Account(name = 'Testaccount001', Dealer_discount__c = 30, RecordTypeId = rectCo[0].Id);
        insert new List<account>{ myAccount1, myAccount2 };
        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 };

            hospitalprice__c hp1 = new hospitalprice__c();
            hp1.hospital__c = myAccount1.Id;
            hp1.account__c = myAccount1.Id;
            hp1.product__c = pro1.Id;
            insert hp1;

            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';
            Order0.OutPattern__c = true;
            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 = 1;
            Orderdet.isOutPattern__c = true;
            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.debug('Orderdet1:' + Orderdet1);
            System.Test.startTest();
            String a = LexSaleOrderController.baseUrl;
            LexSaleOrderController.msiMap = new Map<String, Integer>();
            List<Consumable_orderdetails__c> orderdetails = new List<Consumable_orderdetails__c>();
            orderdetails.add(Orderdet);
            LexSaleOrderController.GoodsDeliveryInit(Order1.Id);
            LexSaleOrderController.consumableorderdetailsRecords[0].outboundCount = 1;
            String condetailList = JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords);
            // LexSaleOrderController.ProdElivery(Order1.Id, LexSaleOrderController.coc, '01049531702003111115120017181000105ZK250BXJRF', myAccount1.Name, '', condetailList, LexSaleOrderController.orderdetails, LexSaleOrderController.orderpriceMap, LexSaleOrderController.orderagencypriceMap);
            LexSaleOrderController.ProSale(
                Order1.Id,
                LexSaleOrderController.coc,
                '01049531702003111115120017181000105ZK250BXJRF',
                myAccount1.Name,
                '',
                condetailList,
                LexSaleOrderController.orderdetails,
                LexSaleOrderController.orderpriceMap,
                LexSaleOrderController.orderagencypriceMap
            );
            System.Test.stopTest();
        }
    }
}
=======
            LexSaleOrderController.SearchPro(Order1,barcode,accountName,userWorkLocation,accountId,orderdetails,orderpieceorboxMap);
            LexSaleOrderController.ProdElivery(ESetId,Order1,barcode,accountName,userWorkLocation,JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords),orderdetails,orderpriceMap,orderagencypriceMap);
            LexSaleOrderController.ProSale(ESetId,Order1,barcode,accountName,userWorkLocation,JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords),orderdetails,orderpriceMap,orderagencypriceMap);
            
            System.Test.stopTest();
        }
    }

    @isTest
    static void searchTest1() {
        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)'];
		Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
		Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id);
		insert new account[]{myAccount1,myAccount2};
		Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.id);
		insert core;
		user MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com',UserPro_Type__c = 'ET',Work_Location__c='北京');
		System.runAs(new User(Id = UserInfo.getUserId())){
            insert MyUser_Test;
        }
        
		System.runAs(MyUser_Test){
            Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',JANCODE__c = '04953170200311',Dealer_special_Object__c = true,Manual_Entry__c = false);
			Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',JANCODE__c = '04953170200312',Dealer_special_Object__c = true,Manual_Entry__c = false);
			insert new Product2[] {prod01,prod02};
			Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='N3047730',Product2__c = prod01.Id);
			Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='N3047731',Product2__c = prod02.Id);
			insert new Product2__c[] {pro1, pro2};
            
            hospitalprice__c hp1 = new hospitalprice__c();
            hp1.hospital__c = myAccount1.Id;
            hp1.account__c = myAccount1.Id;
            hp1.product__c = pro1.Id;
            insert hp1;

            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';
            Order0.OutPattern__c = true;
			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 = 1;
            Orderdet.isOutPattern__c = true;
			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;
			insert Orderdet1;
			System.debug('Orderdet1:'+Orderdet1);
			Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
			Orderdet2.Name = 'OCM_01_001001';
			Orderdet2.Consumable_order_minor__c = Order1.Id;
			Orderdet2.Consumable_Product__c = pro1.Id;
			Orderdet2.Asset_Model_No__c = 'Test01';
			Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
			Orderdet2.Bar_Code__c = '01049531702003111115120017181234105ZK250BXJRF';
			Orderdet1.Cancellation_Date__c = null;
			Orderdet2.TracingCode__c = 'BXJRF';
			Orderdet2.SerialLotNo__c = '5ZK';
            // Orderdet2.Consumable_ZS_order__c = Order1.Id;
            // Orderdet2.Box_Piece__c = '个';
			insert Orderdet2;
			System.Test.startTest();
			String a = LexSaleOrderController.baseUrl;
            LexSaleOrderController.msiMap = new Map<String, Integer>();
            List<Consumable_orderdetails__c> orderdetails = new List<Consumable_orderdetails__c>();
            orderdetails.add(Orderdet);
            LexSaleOrderController.GoodsDeliveryInit(Order1.Id);
            String condetailList = JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords);
            Order1.Arrive_Order__c = null;
			LexSaleOrderController.SearchPro(Order1, '01049531702003111115120017181000105ZK250BXJRF', myAccount1.Name, '', myAccount1.Id, LexSaleOrderController.orderdetails, LexSaleOrderController.orderpieceorboxMap);
			LexSaleOrderController.ProdElivery(Order1.Id, LexSaleOrderController.coc, '01049531702003111115120017181000105ZK250BXJRF', myAccount1.Name, '', condetailList, LexSaleOrderController.orderdetails, LexSaleOrderController.orderpriceMap, LexSaleOrderController.orderagencypriceMap);
            LexSaleOrderController.ProSale(Order1.Id, LexSaleOrderController.coc, '01049531702003111115120017181000105ZK250BXJRF', myAccount1.Name, '', condetailList, LexSaleOrderController.orderdetails, LexSaleOrderController.orderpriceMap, LexSaleOrderController.orderagencypriceMap);
            System.Test.stopTest();
		}
	}

    @isTest
    static void searchTest2() {
        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)'];
		Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
		Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id);
		insert new account[]{myAccount1,myAccount2};
		Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.id);
		insert core;
		user MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com',UserPro_Type__c = 'ET',Work_Location__c='北京');
		System.runAs(new User(Id = UserInfo.getUserId())){
            insert MyUser_Test;
        }
        
		System.runAs(MyUser_Test){
            Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',JANCODE__c = '04953170200311',Dealer_special_Object__c = true,Manual_Entry__c = false);
			Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',JANCODE__c = '04953170200312',Dealer_special_Object__c = true,Manual_Entry__c = false);
			insert new Product2[] {prod01,prod02};
			Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='N3047730',Product2__c = prod01.Id);
			Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='N3047731',Product2__c = prod02.Id);
			insert new Product2__c[] {pro1, pro2};
            
            hospitalprice__c hp1 = new hospitalprice__c();
            hp1.hospital__c = myAccount1.Id;
            hp1.account__c = myAccount1.Id;
            hp1.product__c = pro1.Id;
            insert hp1;

            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';
            Order0.OutPattern__c = true;
			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 = 1;
            Orderdet.isOutPattern__c = true;
			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.debug('Orderdet1:'+Orderdet1);
			System.Test.startTest();
			String a = LexSaleOrderController.baseUrl;
            LexSaleOrderController.msiMap = new Map<String, Integer>();
            List<Consumable_orderdetails__c> orderdetails = new List<Consumable_orderdetails__c>();
            orderdetails.add(Orderdet);
            LexSaleOrderController.GoodsDeliveryInit(Order1.Id);
            LexSaleOrderController.consumableorderdetailsRecords[0].outboundCount = 1;
            String condetailList = JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords);
            LexSaleOrderController.ProdElivery(Order1.Id, LexSaleOrderController.coc, '01049531702003111115120017181000105ZK250BXJRF', myAccount1.Name, '', condetailList, LexSaleOrderController.orderdetails, LexSaleOrderController.orderpriceMap, LexSaleOrderController.orderagencypriceMap);
            // LexSaleOrderController.ProSale(Order1.Id, LexSaleOrderController.coc, '01049531702003111115120017181000105ZK250BXJRF', myAccount1.Name, '', condetailList, LexSaleOrderController.orderdetails, LexSaleOrderController.orderpriceMap, LexSaleOrderController.orderagencypriceMap);
            System.Test.stopTest();
		}
	}

    @isTest
    static void searchTest3() {
        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)'];
		Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
		Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id);
		insert new account[]{myAccount1,myAccount2};
		Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.id);
		insert core;
		user MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com',UserPro_Type__c = 'ET',Work_Location__c='北京');
		System.runAs(new User(Id = UserInfo.getUserId())){
            insert MyUser_Test;
        }
        
		System.runAs(MyUser_Test){
            Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',JANCODE__c = '04953170200311',Dealer_special_Object__c = true,Manual_Entry__c = false);
			Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',JANCODE__c = '04953170200312',Dealer_special_Object__c = true,Manual_Entry__c = false);
			insert new Product2[] {prod01,prod02};
			Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='N3047730',Product2__c = prod01.Id);
			Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='N3047731',Product2__c = prod02.Id);
			insert new Product2__c[] {pro1, pro2};
            
            hospitalprice__c hp1 = new hospitalprice__c();
            hp1.hospital__c = myAccount1.Id;
            hp1.account__c = myAccount1.Id;
            hp1.product__c = pro1.Id;
            insert hp1;

            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';
            Order0.OutPattern__c = true;
			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 = 1;
            Orderdet.isOutPattern__c = true;
			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.debug('Orderdet1:'+Orderdet1);
			System.Test.startTest();
			String a = LexSaleOrderController.baseUrl;
            LexSaleOrderController.msiMap = new Map<String, Integer>();
            List<Consumable_orderdetails__c> orderdetails = new List<Consumable_orderdetails__c>();
            orderdetails.add(Orderdet);
            LexSaleOrderController.GoodsDeliveryInit(Order1.Id);
            LexSaleOrderController.consumableorderdetailsRecords[0].outboundCount = 1;
            String condetailList = JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords);
            // LexSaleOrderController.ProdElivery(Order1.Id, LexSaleOrderController.coc, '01049531702003111115120017181000105ZK250BXJRF', myAccount1.Name, '', condetailList, LexSaleOrderController.orderdetails, LexSaleOrderController.orderpriceMap, LexSaleOrderController.orderagencypriceMap);
            LexSaleOrderController.ProSale(Order1.Id, LexSaleOrderController.coc, '01049531702003111115120017181000105ZK250BXJRF', myAccount1.Name, '', condetailList, LexSaleOrderController.orderdetails, LexSaleOrderController.orderpriceMap, LexSaleOrderController.orderagencypriceMap);
            System.Test.stopTest();
		}
	}
}
>>>>>>> LEXCommunityLiJun
