From 744f42c5496e656a1f9927740a3b37c0b97a6cba Mon Sep 17 00:00:00 2001 From: buli <137736985@qq.com> Date: 星期五, 14 七月 2023 14:34:12 +0800 Subject: [PATCH] lexcommunityupload0714 --- force-app/main/default/classes/LexInventoryControllerTest.cls | 1837 ++++++++++++++++++++++------------------------------------ 1 files changed, 694 insertions(+), 1,143 deletions(-) diff --git a/force-app/main/default/classes/LexInventoryControllerTest.cls b/force-app/main/default/classes/LexInventoryControllerTest.cls index 2f497df..25646d5 100644 --- a/force-app/main/default/classes/LexInventoryControllerTest.cls +++ b/force-app/main/default/classes/LexInventoryControllerTest.cls @@ -1,1179 +1,730 @@ @isTest public class LexInventoryControllerTest { - static testMethod void InventoryControllerTest_PartBar() { - user myUser_test; - Account myAccount1; - User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; - System.runAs(thisUser) { - Profile prof1 = [ - SELECT Id - FROM Profile - WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)' - ]; - List<RecordType> rectCo = [ - SELECT Id - FROM RecordType - WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�' - ]; - if (rectCo.size() == 0) { - return; - } - StaticParameter.EscapeOrderDetail2Trigger = true; - StaticParameter.EscapeConsumableOrderDetail2Trigger = true; - RecordType rectCoO = [ - SELECT Id - FROM RecordType - WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌' - ]; + static testMethod void InventoryControllerTest_PartBar(){ + user myUser_test; + Account myAccount1; + User thisUser = [ select Id from User where Id = :UserInfo.getUserId()]; + System.runAs(thisUser){ + Profile prof1 = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)']; + List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�']; + if (rectCo.size() == 0) { + return; + } + StaticParameter.EscapeOrderDetail2Trigger = true; + StaticParameter.EscapeConsumableOrderDetail2Trigger = true; + RecordType rectCoO = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌']; - Account olympus = new Account( - RecordTypeId = rectCoO.Id, - AgentCode_Ext__c = '9999900', - Name = 'olympus' - ); - insert olympus; + Account olympus = new Account(RecordTypeId = rectCoO.Id, AgentCode_Ext__c = '9999900', Name = 'olympus'); + insert olympus; - myAccount1 = new Account( - name = 'Testaccount001', - Dealer_discount__c = 10, - RecordTypeId = rectCo[0].Id, - AgentCode_Ext__c = '8888888' - ); - insert myAccount1; + myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '8888888'); + insert myAccount1; - Contact core = new Contact( - email = 'jplumber@salesforce.com', - firstname = 'Joe', - lastname = 'Plumber', - accountid = myAccount1.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 = prof1.Id, - TimeZoneSidKey = 'Asia/Shanghai', - UserName = 'testUser@testorg.com', - Work_Location__c = '涓婃捣' - ); - insert MyUser_Test; - } - System.runAs(MyUser_Test) { - Product2 prod07 = new Product2( - Name = 'Test07', - ProductCode = 'Test07', - Asset_Model_No__c = 'Test07', - SFDA_Status__c = '鏈夊姽', - Dealer_special_Object__c = true, - Packing_list_manual__c = 1, - Manual_Entry__c = false - ); - Product2 prod08 = new Product2( - Name = 'Test08', - ProductCode = 'Test08', - Asset_Model_No__c = 'Test08', - SFDA_Status__c = '鏈夊姽', - Dealer_special_Object__c = true, - Packing_list_manual__c = 1, - Manual_Entry__c = false - ); - Product2 prod09 = new Product2( - Name = 'Test09', - ProductCode = 'Test09', - Asset_Model_No__c = 'Test09', - SFDA_Status__c = '鏈夊姽', - Dealer_special_Object__c = true, - Packing_list_manual__c = 1, - Manual_Entry__c = false - ); + Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.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 = prof1.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com',Work_Location__c = '涓婃捣'); + insert MyUser_Test; - insert new List<Product2>{ prod07, prod08, prod09 }; + } + system.runAs(MyUser_Test){ + Product2 prod07 = new Product2(Name='Test07',ProductCode='Test07',Asset_Model_No__c = 'Test07',SFDA_Status__c = '鏈夊姽',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false); + Product2 prod08 = new Product2(Name='Test08',ProductCode='Test08',Asset_Model_No__c = 'Test08',SFDA_Status__c = '鏈夊姽',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false); + Product2 prod09 = new Product2(Name='Test09',ProductCode='Test09',Asset_Model_No__c = 'Test09',SFDA_Status__c = '鏈夊姽',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false); + + insert new Product2[] {prod07,prod08,prod09}; - //鍒朵綔浜у搧 - Product2__c proG = new Product2__c( - Name = 'MH-155:鐧藉钩琛″附', - OT_CODE_Text__c = 'Test001', - Product2__c = prod07.Id - ); - insert proG; - Product2__c proH = new Product2__c( - Name = 'MB-677:BNC鐢电紗', - OT_CODE_Text__c = 'Test002', - Product2__c = prod08.Id - ); - insert proH; - Product2__c proF = new Product2__c( - Name = 'TooMAJ-643R:姘村泭闉樼003', - OT_CODE_Text__c = 'Test003', - Product2__c = prod09.Id - ); - insert proF; + //鍒朵綔浜у搧 + Product2__c proG = new Product2__c(Name='MH-155:鐧藉钩琛″附',OT_CODE_Text__c='Test001',Product2__c = prod07.Id); + insert proG; + Product2__c proH = new Product2__c(Name='MB-677:BNC鐢电紗',OT_CODE_Text__c='Test002',Product2__c = prod08.Id); + insert proH; + Product2__c proF = new Product2__c(Name='TooMAJ-643R:姘村泭闉樼003',OT_CODE_Text__c='Test003',Product2__c = prod09.Id); + insert proF; + + //棰勫埗澶存槑缁� + Consumable_order__c CreateId = new Consumable_order__c(); + CreateId.Name = 'testMing'; + CreateId.Order_status__c = '鑽夋涓�'; + CreateId.RecordTypeid = System.Label.RT_ConOrder_Order; + CreateId.Dealer_Info__c = myAccount1.id; + CreateId.Inventory_date__c = Date.today(); + CreateId.Order_type__c = '鐩樼偣'; + CreateId.Order_ProType__c = 'ET'; + insert CreateId; + List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>(); + + + //鍒朵綔Consumable_order_details__c-------ProductCount + Consumable_order_details2__c dataForProductCount9 = new Consumable_order_details2__c(); + dataForProductCount9.Bar_Code__c = '1234567890'; + dataForProductCount9.Sterilization_limit__c = Date.today().addDays(2); + dataForProductCount9.Arrive_date__c = Date.today(); + dataForProductCount9.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; + dataForProductCount9.Consumable_Product__c = proG.id; + dataForProductCount9.Asset_Model_No__c = proG.Asset_Model_No__c; + dataForProductCount9.Box_Piece__c = '鐩�'; + dataForProductCount9.Consumable_order_minor__c = CreateId.id; + dataForProductCount9.Send_Date__c = null; + dataForProductCount9.Used_date__c = null; + dataForProductCount9.Lose_Flag__c = false; + conList.add(dataForProductCount9); - //棰勫埗澶存槑缁� - Consumable_order__c CreateId = new Consumable_order__c(); - CreateId.Name = 'testMing'; - CreateId.Order_status__c = '鑽夋涓�'; - CreateId.RecordTypeid = System.Label.RT_ConOrder_Order; - CreateId.Dealer_Info__c = myAccount1.id; - CreateId.Inventory_date__c = Date.today(); - CreateId.Order_type__c = '鐩樼偣'; - CreateId.Order_ProType__c = 'ET'; - insert CreateId; - List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>(); + Consumable_order_details2__c dataForProductCount7 = new Consumable_order_details2__c(); + dataForProductCount7.Bar_Code__c = '1234567892'; + dataForProductCount7.Sterilization_limit__c = Date.today().addDays(2); + dataForProductCount7.Arrive_date__c = Date.today(); + dataForProductCount7.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; + dataForProductCount7.Consumable_Product__c = proH.id; + dataForProductCount7.Asset_Model_No__c = proH.Asset_Model_No__c; + dataForProductCount7.Box_Piece__c = '鐩�'; + dataForProductCount7.Consumable_order_minor__c = CreateId.id; + dataForProductCount7.Send_Date__c = null; + dataForProductCount7.Used_date__c = null; + dataForProductCount7.Lose_Flag__c = false; + conList.add(dataForProductCount7); + + Consumable_order_details2__c dataForProductCount = new Consumable_order_details2__c(); + dataForProductCount.Bar_Code__c = '1234567882'; + dataForProductCount.Sterilization_limit__c = Date.today().addDays(2); + dataForProductCount.Arrive_date__c = Date.today(); + dataForProductCount.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; + dataForProductCount.Consumable_Product__c = proG.id; + dataForProductCount.Asset_Model_No__c = proG.Asset_Model_No__c; + dataForProductCount.Box_Piece__c = '鐩�'; + dataForProductCount.Consumable_order_minor__c = CreateId.id; + dataForProductCount.Send_Date__c = null; + dataForProductCount.Used_date__c = null; + dataForProductCount.Lose_Flag__c = true; + conList.add(dataForProductCount); + + Consumable_order_details2__c dataForProductCount4 = new Consumable_order_details2__c(); + dataForProductCount4.Bar_Code__c = '1234567884'; + dataForProductCount4.Sterilization_limit__c = Date.today().addDays(2); + dataForProductCount4.Arrive_date__c = Date.today(); + dataForProductCount4.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; + dataForProductCount4.Consumable_Product__c = proF.id; + dataForProductCount4.Asset_Model_No__c = proF.Asset_Model_No__c; + dataForProductCount4.Box_Piece__c = '涓�'; + dataForProductCount4.Consumable_order_minor__c = CreateId.id; + //dataForProductCount4.Lose_Flag__c = true; + dataForProductCount4.RemoveBox_No__c = 1; - //鍒朵綔Consumable_order_details__c-------ProductCount - Consumable_order_details2__c dataForProductCount9 = new Consumable_order_details2__c(); - dataForProductCount9.Bar_Code__c = '1234567890'; - dataForProductCount9.Sterilization_limit__c = Date.today().addDays(2); - dataForProductCount9.Arrive_date__c = Date.today(); - dataForProductCount9.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; - dataForProductCount9.Consumable_Product__c = proG.id; - dataForProductCount9.Asset_Model_No__c = proG.Asset_Model_No__c; - dataForProductCount9.Box_Piece__c = '鐩�'; - dataForProductCount9.Consumable_order_minor__c = CreateId.id; - dataForProductCount9.Send_Date__c = null; - dataForProductCount9.Used_date__c = null; - dataForProductCount9.Lose_Flag__c = false; - conList.add(dataForProductCount9); + conList.add(dataForProductCount4); - Consumable_order_details2__c dataForProductCount7 = new Consumable_order_details2__c(); - dataForProductCount7.Bar_Code__c = '1234567892'; - dataForProductCount7.Sterilization_limit__c = Date.today().addDays(2); - dataForProductCount7.Arrive_date__c = Date.today(); - dataForProductCount7.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; - dataForProductCount7.Consumable_Product__c = proH.id; - dataForProductCount7.Asset_Model_No__c = proH.Asset_Model_No__c; - dataForProductCount7.Box_Piece__c = '鐩�'; - dataForProductCount7.Consumable_order_minor__c = CreateId.id; - dataForProductCount7.Send_Date__c = null; - dataForProductCount7.Used_date__c = null; - dataForProductCount7.Lose_Flag__c = false; - conList.add(dataForProductCount7); + Consumable_order_details2__c dataForProductCount5 = new Consumable_order_details2__c(); + dataForProductCount5.Bar_Code__c = '1234567885'; + dataForProductCount5.Sterilization_limit__c = Date.today().addDays(2); + dataForProductCount5.Arrive_date__c = Date.today(); + dataForProductCount5.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; + dataForProductCount5.Consumable_Product__c = proH.id; + dataForProductCount5.Asset_Model_No__c = proH.Asset_Model_No__c; + dataForProductCount5.Box_Piece__c = '涓�'; + dataForProductCount5.Consumable_order_minor__c = CreateId.id; + dataForProductCount5.Lose_Flag__c = true; + dataForProductCount5.RemoveBox_No__c = 1; + conList.add(dataForProductCount5); + insert conList; + + List<Consumable_order_details2__c> productCount_Res = [select Id,Name + FROM Consumable_order_details2__c + WHERE Dealer_Arrive__c = true + AND Dealer_Shipment__c = false + AND Dealer_Saled__c = false + AND Lose_Flag__c = false + AND Bar_Code__c !=null + AND Dealer_Info_text__c = :myAccount1.Name]; + //鏌ヨ搴撳瓨 杩藉姞杩斿搧搴撳瓨 - Consumable_order_details2__c dataForProductCount = new Consumable_order_details2__c(); - dataForProductCount.Bar_Code__c = '1234567882'; - dataForProductCount.Sterilization_limit__c = Date.today().addDays(2); - dataForProductCount.Arrive_date__c = Date.today(); - dataForProductCount.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; - dataForProductCount.Consumable_Product__c = proG.id; - dataForProductCount.Asset_Model_No__c = proG.Asset_Model_No__c; - dataForProductCount.Box_Piece__c = '鐩�'; - dataForProductCount.Consumable_order_minor__c = CreateId.id; - dataForProductCount.Send_Date__c = null; - dataForProductCount.Used_date__c = null; - dataForProductCount.Lose_Flag__c = true; - conList.add(dataForProductCount); + List<Consumable_order_details2__c> conList1 = new List<Consumable_order_details2__c>(); + Consumable_order_details2__c con = new Consumable_order_details2__c(); + con.Arrive_date__c = Date.today(); + con.Send_Date__c = null; + con.Used_date__c = null; + con.Return_date__c = null; + con.Lose_Flag__c = false; + con.Cancellation_Flag__c = false; + con.Consumable_Product__c = proG.Id; + con.Asset_Model_No__c = 'Mj-1001'; + con.Sterilization_limit__c = Date.today().addDays(2); + con.Box_Piece__c = '鐩�'; + con.Consumable_order_minor__c = CreateId.id; + con.Bar_Code__c = '1234567885'; + conList1.add(con); - Consumable_order_details2__c dataForProductCount4 = new Consumable_order_details2__c(); - dataForProductCount4.Bar_Code__c = '1234567884'; - dataForProductCount4.Sterilization_limit__c = Date.today().addDays(2); - dataForProductCount4.Arrive_date__c = Date.today(); - dataForProductCount4.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; - dataForProductCount4.Consumable_Product__c = proF.id; - dataForProductCount4.Asset_Model_No__c = proF.Asset_Model_No__c; - dataForProductCount4.Box_Piece__c = '涓�'; - dataForProductCount4.Consumable_order_minor__c = CreateId.id; - //dataForProductCount4.Lose_Flag__c = true; - dataForProductCount4.RemoveBox_No__c = 1; + Consumable_order_details2__c con1 = new Consumable_order_details2__c(); + con1.Arrive_date__c = Date.today(); + con1.Send_Date__c = null; + con1.Used_date__c = null; + con1.Return_date__c = null; + con1.Lose_Flag__c = false; + con1.Cancellation_Flag__c = false; + con1.Consumable_Product__c = proG.Id; + con1.Asset_Model_No__c = 'Mj-1001'; + con1.Sterilization_limit__c = Date.today().addDays(2); + con1.Box_Piece__c = '涓�'; + con1.Consumable_order_minor__c = CreateId.id; + con1.Bar_Code__c = '12345678856'; + conList1.add(con1); + insert conList1; + + LexInventoryController OwnTest = new LexInventoryController(); + LexInventoryController.init(); + LexInventoryController controller = new LexInventoryController(); + List<LexInventoryController.ConsumableorderdetailsInfo> testList = LexInventoryController.consumableorderdetailsRecords; + List<LexInventoryController.ConsumableorderdetailsInfo> testList1 = new List<LexInventoryController.ConsumableorderdetailsInfo>(); + System.debug('testCount:'+testList.size()); + for(LexInventoryController.ConsumableorderdetailsInfo ass : testList){ + System.debug(ass.check); + ass.check = true; + testList1.add(ass); + } + System.debug('testList1:'+testList1); + LexInventoryController.searchConsumableorderdetails('ET','涓婃捣','Testaccount001','12345678856\n1234567895\n1234567890\n12345678511\n1234567856\n1234567855\n1234567886\n12345678551\n1234567890\n1234567883\n1234567882\n1234567881\n1234567884\nn123456788412\n1234567885\n123456788512\n1234567891\n1234567892\n1234567893\n1234567894',JSON.serialize(testList1),1,0,'Test','ASC'); + LexInventoryController.searchConsumableorderdetails('ET','涓婃捣','Testaccount001','1234567882',JSON.serialize(testList1),1,0,'Test','ASC'); + LexInventoryController.barcode = ''; + + } + } + static testMethod void InventoryControllerTest_PartPan(){ + user MyUser_Test; + Account myAccount1; + User thisUser = [ select Id from User where Id = :UserInfo.getUserId()]; + system.runAs(thisUser){ + + Profile prof1 = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)']; + List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�']; + if (rectCo.size() == 0) { + return; + } + RecordType rectCoO = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌']; + Account olympus = new Account(RecordTypeId = rectCoO.Id, AgentCode_Ext__c = '9999900', Name = 'olympus'); + insert olympus; + + Product2 prod07 = new Product2(Name='Test07',ProductCode='Test07',Asset_Model_No__c = 'Test07',SFDA_Status__c = '鏈夊姽',Dealer_special_Object__c = true); + Product2 prod08 = new Product2(Name='Test08',ProductCode='Test08',Asset_Model_No__c = 'Test08',SFDA_Status__c = '鏈夊姽',Dealer_special_Object__c = true); + Product2 prod09 = new Product2(Name='Test09',ProductCode='Test09',Asset_Model_No__c = 'Test09',SFDA_Status__c = '鏈夊姽',Dealer_special_Object__c = true); + insert new Product2[] {prod07,prod08,prod09}; + + //鍒朵綔浜у搧 + Product2__c proG = new Product2__c(Name='Too001',OT_CODE_Text__c='Test001',Product2__c = prod07.Id); + insert proG; + Product2__c proH = new Product2__c(Name='Too002',OT_CODE_Text__c='Test002',Product2__c = prod08.Id); + insert proH; + Product2__c proF = new Product2__c(Name='Too003',OT_CODE_Text__c='Test001',Product2__c = prod09.Id); + insert proF; + + + myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id); + + insert myAccount1; + + Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.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 = prof1.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com'); + insert MyUser_Test; + } + system.runAs(MyUser_Test){ + + InventoryController OwnTest = new InventoryController(); + OwnTest.size = 2; + OwnTest.init(); + OwnTest.setCon.next(); + OwnTest.refreshPageSize(); + OwnTest.ConsumableorderdetailsRecordsview.sort(); + system.assertEquals(0,OwnTest.consumableorderdetailsCount); + OwnTest.save(); + } + } + static testMethod void InventoryControllerTest_ge(){ + user MyUser_Test; + Account myAccount1; + User thisUser = [ select Id from User where Id = :UserInfo.getUserId()]; + system.runAs(thisUser){ + + + Profile prof1 = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)']; + List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�']; + if (rectCo.size() == 0) { + return; + } + StaticParameter.EscapeConsumableOrderDetail2Trigger = true; + + RecordType rectCoO = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌']; + Account olympus = new Account(RecordTypeId = rectCoO.Id, AgentCode_Ext__c = '9999900', Name = 'olympus'); + insert olympus; + myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '8888888'); + insert myAccount1; + Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.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 = prof1.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com'); + insert MyUser_Test; + } + system.runAs(MyUser_Test){ + + Product2 prod07 = new Product2(Name='Test07',ProductCode='Test07',Asset_Model_No__c = 'Test07',SFDA_Status__c = '鏈夊姽',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false); + Product2 prod08 = new Product2(Name='Test08',ProductCode='Test08',Asset_Model_No__c = 'Test08',SFDA_Status__c = '鏈夊姽',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false); + Product2 prod09 = new Product2(Name='Test09',ProductCode='Test09',Asset_Model_No__c = 'Test09',SFDA_Status__c = '鏈夊姽',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false); + insert new Product2[] {prod07,prod08,prod09}; - conList.add(dataForProductCount4); + //鍒朵綔浜у搧 + Product2__c proG = new Product2__c(Name='MH-155:鐧藉钩琛″附',OT_CODE_Text__c='Test001',Product2__c = prod07.Id); + insert proG; + Product2__c proH = new Product2__c(Name='MB-677:BNC鐢电紗',OT_CODE_Text__c='Test002',Product2__c = prod08.Id); + insert proH; + Product2__c proF = new Product2__c(Name='TooMAJ-643R:姘村泭闉樼003',OT_CODE_Text__c='Test003',Product2__c = prod09.Id); + insert proF; + + //棰勫埗澶存槑缁� + Consumable_order__c CreateId = new Consumable_order__c(); + CreateId.Name = 'testMing'; + CreateId.Order_status__c = '鑽夋涓�'; + CreateId.RecordTypeid = System.Label.RT_ConOrder_Order; + CreateId.Dealer_Info__c = myAccount1.id; + CreateId.Inventory_date__c = Date.today(); + CreateId.Order_type__c = '鐩樼偣'; + CreateId.Order_ProType__c = 'ET'; + insert CreateId; + List<Consumable_order_details2__c> orderList = new List<Consumable_order_details2__c>(); + + + //鍒朵綔Consumable_order_details__c-------ProductCount + Consumable_order_details2__c dataForProductCount9 = new Consumable_order_details2__c(); + dataForProductCount9.Bar_Code__c = '1234567890'; + dataForProductCount9.Sterilization_limit__c = Date.today().addDays(2); + dataForProductCount9.Arrive_date__c = Date.today(); + dataForProductCount9.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; + dataForProductCount9.Consumable_Product__c = proG.id; + dataForProductCount9.Asset_Model_No__c = proG.Asset_Model_No__c; + dataForProductCount9.Box_Piece__c = '涓�'; + dataForProductCount9.RemoveBox_No__c = 1; + orderList.add(dataForProductCount9); - Consumable_order_details2__c dataForProductCount5 = new Consumable_order_details2__c(); - dataForProductCount5.Bar_Code__c = '1234567885'; - dataForProductCount5.Sterilization_limit__c = Date.today().addDays(2); - dataForProductCount5.Arrive_date__c = Date.today(); - dataForProductCount5.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; - dataForProductCount5.Consumable_Product__c = proH.id; - dataForProductCount5.Asset_Model_No__c = proH.Asset_Model_No__c; - dataForProductCount5.Box_Piece__c = '涓�'; - dataForProductCount5.Consumable_order_minor__c = CreateId.id; - dataForProductCount5.Lose_Flag__c = true; - dataForProductCount5.RemoveBox_No__c = 1; - conList.add(dataForProductCount5); - insert conList; + Consumable_order_details2__c dataForProductCount8 = new Consumable_order_details2__c(); + dataForProductCount8.Bar_Code__c = '1234567891'; + dataForProductCount8.Sterilization_limit__c = Date.today().addDays(2); + dataForProductCount8.Arrive_date__c = Date.today(); + dataForProductCount8.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; + dataForProductCount8.Consumable_Product__c = proG.id; + dataForProductCount8.Asset_Model_No__c = proG.Asset_Model_No__c; + orderList.add(dataForProductCount8); - List<Consumable_order_details2__c> productCount_Res = [ - SELECT Id, Name - FROM Consumable_order_details2__c - WHERE - Dealer_Arrive__c = TRUE - AND Dealer_Shipment__c = FALSE - AND Dealer_Saled__c = FALSE - AND Lose_Flag__c = FALSE - AND Bar_Code__c != NULL - AND Dealer_Info_text__c = :myAccount1.Name - ]; - //鏌ヨ搴撳瓨 杩藉姞杩斿搧搴撳瓨 + Consumable_order_details2__c dataForProductCount7 = new Consumable_order_details2__c(); + dataForProductCount7.Bar_Code__c = '1234567892'; + dataForProductCount7.Sterilization_limit__c = Date.today().addDays(2); + dataForProductCount7.Arrive_date__c = Date.today(); + dataForProductCount7.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; + dataForProductCount7.Consumable_Product__c = proH.id; + dataForProductCount7.Asset_Model_No__c = proH.Asset_Model_No__c; + dataForProductCount7.Box_Piece__c = '涓�'; + dataForProductCount7.Consumable_order_minor__c = CreateId.id; + dataForProductCount7.Send_Date__c = null; + dataForProductCount7.Used_date__c = null; + dataForProductCount7.Lose_Flag__c = false; + dataForProductCount7.RemoveBox_No__c = 1; + orderList.add(dataForProductCount7); + + Consumable_order_details2__c dataForProduct = new Consumable_order_details2__c(); + dataForProduct.Bar_Code__c = '1234567894'; + dataForProduct.Sterilization_limit__c = Date.today().addDays(2); + dataForProduct.Arrive_date__c = Date.today(); + dataForProduct.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; + dataForProduct.Consumable_Product__c = proF.id; + dataForProduct.Asset_Model_No__c = proF.Asset_Model_No__c; + dataForProduct.Box_Piece__c = '涓�'; + dataForProduct.Consumable_order_minor__c = CreateId.id; + dataForProduct.Send_Date__c = null; + dataForProduct.Used_date__c = null; + dataForProduct.Lose_Flag__c = false; + dataForProduct.RemoveBox_No__c = 1; + orderList.add(dataForProduct); + + Consumable_order_details2__c dataForProductCount3 = new Consumable_order_details2__c(); + dataForProductCount3.Bar_Code__c = '1234567883'; + dataForProductCount3.Sterilization_limit__c = Date.today().addDays(2); + dataForProductCount3.Arrive_date__c = Date.today(); + dataForProductCount3.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; + dataForProductCount3.Consumable_Product__c = proG.id; + dataForProductCount3.Asset_Model_No__c = proG.Asset_Model_No__c; + dataForProductCount3.Consumable_order_minor__c = CreateId.id; + dataForProductCount3.Lose_Flag__c = true; + //dataForProductCount3.RemoveBox_No__c = 1; + orderList.add(dataForProductCount3); + + + PageReference page = new Pagereference('/Inventory'); + page.setRedirect(true); + System.Test.setCurrentPage(page); + System.Test.startTest(); + LexInventoryController controller = new LexInventoryController(); + LexInventoryController.init(); + System.debug('===>鍊�1'+LexInventoryController.consumableorderdetailsRecords); + System.debug('===>鍊�2'+ JSON.serialize(LexInventoryController.consumableorderdetailsRecords)); + System.debug('===>2222222'+JSON.serialize(LexInventoryController.consumableorderdetailsRecords)); + List<LexInventoryController.ConsumableorderdetailsInfo> testList = LexInventoryController.consumableorderdetailsRecords; + List<LexInventoryController.ConsumableorderdetailsInfo> testList1 = new List<LexInventoryController.ConsumableorderdetailsInfo>(); + System.debug('testCount:'+testList.size()); + for(LexInventoryController.ConsumableorderdetailsInfo ass : testList){ + System.debug(ass.check); + ass.check = true; + testList1.add(ass); + } + System.debug('testList1:'+testList1); - List<Consumable_order_details2__c> conList1 = new List<Consumable_order_details2__c>(); - Consumable_order_details2__c con = new Consumable_order_details2__c(); - con.Arrive_date__c = Date.today(); - con.Send_Date__c = null; - con.Used_date__c = null; - con.Return_date__c = null; - con.Lose_Flag__c = false; - con.Cancellation_Flag__c = false; - con.Consumable_Product__c = proG.Id; - con.Asset_Model_No__c = 'Mj-1001'; - con.Sterilization_limit__c = Date.today().addDays(2); - con.Box_Piece__c = '鐩�'; - con.Consumable_order_minor__c = CreateId.id; - con.Bar_Code__c = '1234567885'; - conList1.add(con); + LexInventoryController.searchConsumableorderdetails('ET','涓婃捣','Testaccount001','12345678856\n1234567895\n1234567890\n12345678511\n1234567856\n1234567855\n1234567886\n12345678551\n1234567890\n1234567883\n1234567882\n1234567881\n1234567884\nn123456788412\n1234567885\n123456788512\n1234567891\n1234567892\n1234567893\n1234567894',JSON.serialize(testList1),1,0,'Test','ASC'); + System.Test.stopTest(); + } + } + static testMethod void InventoryControllerTest_xunhui(){ + user MyUser_Test; + Account myAccount1; + User thisUser = [ select Id from User where Id = :UserInfo.getUserId()]; + system.runAs(thisUser){ + Profile prof1 = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)']; + List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�']; + if (rectCo.size() == 0) { + return; + } + StaticParameter.EscapeOrderDetail2Trigger = true; + StaticParameter.EscapeConsumableOrderDetail2Trigger = true; + RecordType rectCoO = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌']; + Account olympus = new Account(RecordTypeId = rectCoO.Id, AgentCode_Ext__c = '9999900', Name = 'olympus'); + insert olympus; + myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '8888888'); + insert myAccount1; + Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.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 = prof1.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com'); + insert MyUser_Test; + } + system.runAs(MyUser_Test){ + + Product2 prod07 = new Product2(Name='Test07',ProductCode='Test07',Asset_Model_No__c = 'Test07',SFDA_Status__c = '鏈夊姽',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false); + Product2 prod08 = new Product2(Name='Test08',ProductCode='Test08',Asset_Model_No__c = 'Test08',SFDA_Status__c = '鏈夊姽',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false); + Product2 prod09 = new Product2(Name='Test09',ProductCode='Test09',Asset_Model_No__c = 'Test09',SFDA_Status__c = '鏈夊姽',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false); + insert new Product2[] {prod07,prod08,prod09}; - Consumable_order_details2__c con1 = new Consumable_order_details2__c(); - con1.Arrive_date__c = Date.today(); - con1.Send_Date__c = null; - con1.Used_date__c = null; - con1.Return_date__c = null; - con1.Lose_Flag__c = false; - con1.Cancellation_Flag__c = false; - con1.Consumable_Product__c = proG.Id; - con1.Asset_Model_No__c = 'Mj-1001'; - con1.Sterilization_limit__c = Date.today().addDays(2); - con1.Box_Piece__c = '涓�'; - con1.Consumable_order_minor__c = CreateId.id; - con1.Bar_Code__c = '12345678856'; - conList1.add(con1); - insert conList1; + //鍒朵綔浜у搧 + Product2__c proG = new Product2__c(Name='MH-155:鐧藉钩琛″附',OT_CODE_Text__c='Test001',Product2__c = prod07.Id); + insert proG; + Product2__c proH = new Product2__c(Name='MB-677:BNC鐢电紗',OT_CODE_Text__c='Test002',Product2__c = prod08.Id); + insert proH; + Product2__c proF = new Product2__c(Name='TooMAJ-643R:姘村泭闉樼003',OT_CODE_Text__c='Test003',Product2__c = prod09.Id); + insert proF; + + //棰勫埗澶存槑缁� + Consumable_order__c CreateId = new Consumable_order__c(); + CreateId.Name = 'testMing'; + CreateId.Order_status__c = '鑽夋涓�'; + CreateId.RecordTypeid = System.Label.RT_ConOrder_Order; + CreateId.Dealer_Info__c = myAccount1.id; + CreateId.Inventory_date__c = Date.today(); + CreateId.Order_type__c = '鐩樼偣'; + CreateId.Order_ProType__c = 'ET'; + insert CreateId; + List<Consumable_order__c> orderList = new List<Consumable_order__c>(); + //鍒拌揣 + Consumable_order__c Order1 = new Consumable_order__c(); + Order1.Name = 'OCM_01'; + Order1.Order_status__c = '鎵瑰噯'; + Order1.Order_type__c = '鍒拌揣'; + Order1.Dealer_Info__c = myAccount1.Id; + Order1.RecordTypeid = '01210000000c9dqAAA'; + Order1.Order_ProType__c = 'ENG'; + orderList.add(Order1); + //鍙戣揣 + Consumable_order__c Order2 = new Consumable_order__c(); + Order2.Name = 'OCM_01'; + Order2.Order_status__c = '鎵瑰噯'; + Order2.Order_type__c = '璁㈠崟 '; + Order2.Dealer_Info__c = myAccount1.Id; + Order2.RecordTypeid = '01210000000c9drAAA'; + Order2.Order_ProType__c = 'ENG'; + orderList.add(Order2); + insert orderList; - LexInventoryController OwnTest = new LexInventoryController(); - LexInventoryController.init(); - LexInventoryController controller = new LexInventoryController(); - List<LexInventoryController.ConsumableorderdetailsInfo> testList = LexInventoryController.consumableorderdetailsRecords; - List<LexInventoryController.ConsumableorderdetailsInfo> testList1 = new List<LexInventoryController.ConsumableorderdetailsInfo>(); - System.debug('testCount:' + testList.size()); - for (LexInventoryController.ConsumableorderdetailsInfo ass : testList) { - System.debug(ass.check); - ass.check = true; - testList1.add(ass); - } - System.debug('testList1:' + testList1); - LexInventoryController.searchConsumableorderdetails( - 'ET', - '涓婃捣', - 'Testaccount001', - '12345678856\n1234567895\n1234567890\n12345678511\n1234567856\n1234567855\n1234567886\n12345678551\n1234567890\n1234567883\n1234567882\n1234567881\n1234567884\nn123456788412\n1234567885\n123456788512\n1234567891\n1234567892\n1234567893\n1234567894', - JSON.serialize(testList1), - 1, - 0, - 'Test', - 'ASC' - ); - LexInventoryController.searchConsumableorderdetails( - 'ET', - '涓婃捣', - 'Testaccount001', - '1234567882', - JSON.serialize(testList1), - 1, - 0, - 'Test', - 'ASC' - ); - LexInventoryController.barcode = ''; - } - } - static testMethod void InventoryControllerTest_PartPan() { - user MyUser_Test; - Account myAccount1; - User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; - System.runAs(thisUser) { - Profile prof1 = [ - SELECT Id - FROM Profile - WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)' - ]; - List<RecordType> rectCo = [ - SELECT Id - FROM RecordType - WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�' - ]; - if (rectCo.size() == 0) { - return; - } - RecordType rectCoO = [ - SELECT Id - FROM RecordType - WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌' - ]; - Account olympus = new Account( - RecordTypeId = rectCoO.Id, - AgentCode_Ext__c = '9999900', - Name = 'olympus' - ); - insert olympus; + + + //鍒朵綔Consumable_order_details__c-------ProductCount + Consumable_order_details2__c dataForProductCount9 = new Consumable_order_details2__c(); + dataForProductCount9.Bar_Code__c = '1234567890'; + dataForProductCount9.Sterilization_limit__c = Date.today().addDays(2); + dataForProductCount9.Arrive_date__c = Date.today(); + dataForProductCount9.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; + dataForProductCount9.Consumable_Product__c = proG.id; + dataForProductCount9.Asset_Model_No__c = proG.Asset_Model_No__c; + dataForProductCount9.Box_Piece__c = '鐩�'; + dataForProductCount9.Consumable_order_minor__c = CreateId.id; + dataForProductCount9.Send_Date__c = null; + dataForProductCount9.Used_date__c = null; + dataForProductCount9.Lose_Flag__c = false; + dataForProductCount9.RemoveBox_No__c = 1; + insert dataForProductCount9; - Product2 prod07 = new Product2( - Name = 'Test07', - ProductCode = 'Test07', - Asset_Model_No__c = 'Test07', - SFDA_Status__c = '鏈夊姽', - Dealer_special_Object__c = true - ); - Product2 prod08 = new Product2( - Name = 'Test08', - ProductCode = 'Test08', - Asset_Model_No__c = 'Test08', - SFDA_Status__c = '鏈夊姽', - Dealer_special_Object__c = true - ); - Product2 prod09 = new Product2( - Name = 'Test09', - ProductCode = 'Test09', - Asset_Model_No__c = 'Test09', - SFDA_Status__c = '鏈夊姽', - Dealer_special_Object__c = true - ); - insert new List<Product2>{ prod07, prod08, prod09 }; + Consumable_order_details2__c dataForProductCount8 = new Consumable_order_details2__c(); + dataForProductCount8.Bar_Code__c = '1234567891'; + dataForProductCount8.Sterilization_limit__c = Date.today().addDays(2); + dataForProductCount8.Arrive_date__c = Date.today(); + dataForProductCount8.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; + dataForProductCount8.Consumable_Product__c = proG.id; + dataForProductCount8.Asset_Model_No__c = proG.Asset_Model_No__c; + dataForProductCount8.Box_Piece__c = '鐩�'; + dataForProductCount8.Consumable_order_minor__c = CreateId.id; + dataForProductCount8.Send_Date__c = null; + dataForProductCount8.Used_date__c = null; + dataForProductCount8.Lose_Flag__c = false; + dataForProductCount8.RemoveBox_No__c = 1; + insert dataForProductCount8; - //鍒朵綔浜у搧 - Product2__c proG = new Product2__c( - Name = 'Too001', - OT_CODE_Text__c = 'Test001', - Product2__c = prod07.Id - ); - insert proG; - Product2__c proH = new Product2__c( - Name = 'Too002', - OT_CODE_Text__c = 'Test002', - Product2__c = prod08.Id - ); - insert proH; - Product2__c proF = new Product2__c( - Name = 'Too003', - OT_CODE_Text__c = 'Test001', - Product2__c = prod09.Id - ); - insert proF; + Consumable_order_details2__c dataForProductCount7 = new Consumable_order_details2__c(); + dataForProductCount7.Bar_Code__c = '1234567892'; + dataForProductCount7.Sterilization_limit__c = Date.today().addDays(2); + dataForProductCount7.Arrive_date__c = Date.today(); + dataForProductCount7.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; + dataForProductCount7.Consumable_Product__c = proH.id; + dataForProductCount7.Asset_Model_No__c = proH.Asset_Model_No__c; + dataForProductCount7.Box_Piece__c = '涓�'; + dataForProductCount7.Consumable_order_minor__c = CreateId.id; + dataForProductCount7.Send_Date__c = null; + dataForProductCount7.Used_date__c = null; + dataForProductCount7.Lose_Flag__c = false; + dataForProductCount7.RemoveBox_No__c = 1; + insert dataForProductCount7; - myAccount1 = new Account( - name = 'Testaccount001', - Dealer_discount__c = 10, - RecordTypeId = rectCo[0].Id - ); + Consumable_order_details2__c dataForProductCount6 = new Consumable_order_details2__c(); + dataForProductCount6.Bar_Code__c = '1234567893'; + dataForProductCount6.Sterilization_limit__c = Date.today().addDays(2); + dataForProductCount6.Arrive_date__c = Date.today(); + dataForProductCount6.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; + dataForProductCount6.Consumable_Product__c = proH.id; + dataForProductCount6.Asset_Model_No__c = proH.Asset_Model_No__c; + dataForProductCount6.Box_Piece__c = '涓�'; + dataForProductCount6.Consumable_order_minor__c = CreateId.id; + dataForProductCount6.Send_Date__c = null; + dataForProductCount6.Used_date__c = null; + dataForProductCount6.Lose_Flag__c = false; + dataForProductCount6.RemoveBox_No__c = 1; + insert dataForProductCount6; - insert myAccount1; + Consumable_order_details2__c dataForProductCount5 = new Consumable_order_details2__c(); + dataForProductCount5.Bar_Code__c = '1234567894'; + dataForProductCount5.Sterilization_limit__c = Date.today().addDays(2); + dataForProductCount5.Arrive_date__c = Date.today(); + dataForProductCount5.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; + dataForProductCount5.Consumable_Product__c = proH.id; + dataForProductCount5.Asset_Model_No__c = proH.Asset_Model_No__c; + dataForProductCount5.Box_Piece__c = '涓�'; + dataForProductCount5.Consumable_order_minor__c = CreateId.id; + dataForProductCount5.Send_Date__c = null; + dataForProductCount5.Used_date__c = null; + dataForProductCount5.Lose_Flag__c = false; + dataForProductCount5.RemoveBox_No__c = 1; + insert dataForProductCount5; - Contact core = new Contact( - email = 'jplumber@salesforce.com', - firstname = 'Joe', - lastname = 'Plumber', - accountid = myAccount1.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 = prof1.Id, - TimeZoneSidKey = 'Asia/Shanghai', - UserName = 'testUser@testorg.com' - ); - insert MyUser_Test; - } - System.runAs(MyUser_Test) { - InventoryController OwnTest = new InventoryController(); - OwnTest.size = 2; - OwnTest.init(); - OwnTest.setCon.next(); - OwnTest.refreshPageSize(); - OwnTest.ConsumableorderdetailsRecordsview.sort(); - system.assertEquals(0, OwnTest.consumableorderdetailsCount); - OwnTest.save(); - } - } - static testMethod void InventoryControllerTest_ge() { - user MyUser_Test; - Account myAccount1; - User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; - System.runAs(thisUser) { - Profile prof1 = [ - SELECT Id - FROM Profile - WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)' - ]; - List<RecordType> rectCo = [ - SELECT Id - FROM RecordType - WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�' - ]; - if (rectCo.size() == 0) { - return; - } - StaticParameter.EscapeConsumableOrderDetail2Trigger = true; + List<Consumable_order_details2__c> conlist = new List<Consumable_order_details2__c>(); + //Barcode妫�绱� 鎵�鏈夊湪搴� + Consumable_order_details2__c con1 = new Consumable_order_details2__c(); + con1.Lose_Flag__c = false; + con1.Arrive_date__c = Date.today(); + con1.Send_Date__c = null; + con1.Return_date__c = null; + con1.Lose_Flag__c = false; + con1.Cancellation_Date__c = null; + con1.Sterilization_limit__c = Date.today().addDays(2); + con1.Bar_Code__c = '123'; + con1.Box_Piece__c = '鐩�'; + con1.Bar_Code__c = '1234567894'; + con1.Sterilization_limit__c = Date.today().addDays(2); + con1.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; + con1.Consumable_Product__c = proH.id; + con1.Consumable_order_minor__c = CreateId.id; + conlist.add(con1); - RecordType rectCoO = [ - SELECT Id - FROM RecordType - WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌' - ]; - Account olympus = new Account( - RecordTypeId = rectCoO.Id, - AgentCode_Ext__c = '9999900', - Name = 'olympus' - ); - insert olympus; - myAccount1 = new Account( - name = 'Testaccount001', - Dealer_discount__c = 10, - RecordTypeId = rectCo[0].Id, - AgentCode_Ext__c = '8888888' - ); - insert myAccount1; - Contact core = new Contact( - email = 'jplumber@salesforce.com', - firstname = 'Joe', - lastname = 'Plumber', - accountid = myAccount1.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 = prof1.Id, - TimeZoneSidKey = 'Asia/Shanghai', - UserName = 'testUser@testorg.com' - ); - insert MyUser_Test; - } - System.runAs(MyUser_Test) { - Product2 prod07 = new Product2( - Name = 'Test07', - ProductCode = 'Test07', - Asset_Model_No__c = 'Test07', - SFDA_Status__c = '鏈夊姽', - Dealer_special_Object__c = true, - Packing_list_manual__c = 1, - Manual_Entry__c = false - ); - Product2 prod08 = new Product2( - Name = 'Test08', - ProductCode = 'Test08', - Asset_Model_No__c = 'Test08', - SFDA_Status__c = '鏈夊姽', - Dealer_special_Object__c = true, - Packing_list_manual__c = 1, - Manual_Entry__c = false - ); - Product2 prod09 = new Product2( - Name = 'Test09', - ProductCode = 'Test09', - Asset_Model_No__c = 'Test09', - SFDA_Status__c = '鏈夊姽', - Dealer_special_Object__c = true, - Packing_list_manual__c = 1, - Manual_Entry__c = false - ); - insert new List<Product2>{ prod07, prod08, prod09 }; + //鏌ヨ搴撳瓨 杩藉姞杩斿搧搴撳瓨 + Consumable_order_details2__c con3 = new Consumable_order_details2__c(); + con3.Consumable_Product__c = proH.id; + con3.Bar_Code__c = '1001'; + con3.Consumable_Arrived_order__c = Order1.id; + con3.Consumable_order_minor__c = Order2.id; + con3.Arrive_date__c = Date.today(); + con3.Send_Date__c = null; + con3.Return_date__c = null; + con3.Lose_Flag__c = false; + con3.Cancellation_Flag__c = false; + con3.Consumable_order_minor__c = CreateId.id; + con3.Sterilization_limit__c = Date.today().addDays(2); + con3.Box_Piece__c = '涓�'; + con3.RecordTypeid = '01210000000kUDKAA2'; + conlist.add(con3); - //鍒朵綔浜у搧 - Product2__c proG = new Product2__c( - Name = 'MH-155:鐧藉钩琛″附', - OT_CODE_Text__c = 'Test001', - Product2__c = prod07.Id - ); - insert proG; - Product2__c proH = new Product2__c( - Name = 'MB-677:BNC鐢电紗', - OT_CODE_Text__c = 'Test002', - Product2__c = prod08.Id - ); - insert proH; - Product2__c proF = new Product2__c( - Name = 'TooMAJ-643R:姘村泭闉樼003', - OT_CODE_Text__c = 'Test003', - Product2__c = prod09.Id - ); - insert proF; + //productAdjust + Consumable_order_details2__c con6 = new Consumable_order_details2__c(); + con6.Consumable_Product__c = proH.id; + con6.Lose_reason__c = '杩囨湡搴撳瓨閿�瀛�'; + con6.Box_Piece__c = '鐩�'; + con6.Sterilization_limit__c = Date.today().addDays(-2); + con6.Bar_Code__c = '10011'; + con6.Consumable_Arrived_order__c = Order1.id; + con6.Lose_Flag__c = true; + con6.RecordTypeid = '01210000000kUDKAA2'; + conlist.add(con6); + System.debug('conlist===>'+conlist); - //棰勫埗澶存槑缁� - Consumable_order__c CreateId = new Consumable_order__c(); - CreateId.Name = 'testMing'; - CreateId.Order_status__c = '鑽夋涓�'; - CreateId.RecordTypeid = System.Label.RT_ConOrder_Order; - CreateId.Dealer_Info__c = myAccount1.id; - CreateId.Inventory_date__c = Date.today(); - CreateId.Order_type__c = '鐩樼偣'; - CreateId.Order_ProType__c = 'ET'; - insert CreateId; - List<Consumable_order_details2__c> orderList = new List<Consumable_order_details2__c>(); - //鍒朵綔Consumable_order_details__c-------ProductCount - Consumable_order_details2__c dataForProductCount9 = new Consumable_order_details2__c(); - dataForProductCount9.Bar_Code__c = '1234567890'; - dataForProductCount9.Sterilization_limit__c = Date.today().addDays(2); - dataForProductCount9.Arrive_date__c = Date.today(); - dataForProductCount9.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; - dataForProductCount9.Consumable_Product__c = proG.id; - dataForProductCount9.Asset_Model_No__c = proG.Asset_Model_No__c; - dataForProductCount9.Box_Piece__c = '涓�'; - dataForProductCount9.RemoveBox_No__c = 1; - orderList.add(dataForProductCount9); + //reset592 + Consumable_order_details2__c con4 = new Consumable_order_details2__c(); + con4.Arrive_date__c = Date.today(); + con4.Send_Date__c = null; + con4.Return_date__c = null; + con4.Lose_Flag__c = false; + con4.Cancellation_Date__c =null; + con4.Sterilization_limit__c = Date.today().addDays(2); + con4.Bar_Code__c = '123456'; + con4.Box_Piece__c = '鐩�'; + // con2.Bar_Code__c = '1234567894'; + con4.Sterilization_limit__c = Date.today().addDays(2); + con4.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; + con4.Consumable_Product__c = proH.id; + // con2.Asset_Model_No__c = proH.Asset_Model_No__c; + con4.Consumable_order_minor__c = CreateId.id; + conlist.add(con4); - Consumable_order_details2__c dataForProductCount8 = new Consumable_order_details2__c(); - dataForProductCount8.Bar_Code__c = '1234567891'; - dataForProductCount8.Sterilization_limit__c = Date.today().addDays(2); - dataForProductCount8.Arrive_date__c = Date.today(); - dataForProductCount8.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; - dataForProductCount8.Consumable_Product__c = proG.id; - dataForProductCount8.Asset_Model_No__c = proG.Asset_Model_No__c; - orderList.add(dataForProductCount8); + + //鏌ヨ搴撳瓨 杩藉姞杩斿搧搴撳瓨 + Consumable_order_details2__c con5 = new Consumable_order_details2__c(); + con5.Arrive_date__c = Date.today(); + con5.Send_Date__c = null; + con5.Return_date__c = null; + con5.Lose_Flag__c = false; + con5.Cancellation_Flag__c = false; + con5.Consumable_Product__c = proH.id; + con5.Consumable_order_minor__c = Order2.id; + // con5.Sterilization_limit__c = Date.today().addDays(2); + con5.Box_Piece__c = '鐩�'; + con5.Bar_Code__c = '1001'; + conlist.add(con5); + insert conlist; - Consumable_order_details2__c dataForProductCount7 = new Consumable_order_details2__c(); - dataForProductCount7.Bar_Code__c = '1234567892'; - dataForProductCount7.Sterilization_limit__c = Date.today().addDays(2); - dataForProductCount7.Arrive_date__c = Date.today(); - dataForProductCount7.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; - dataForProductCount7.Consumable_Product__c = proH.id; - dataForProductCount7.Asset_Model_No__c = proH.Asset_Model_No__c; - dataForProductCount7.Box_Piece__c = '涓�'; - dataForProductCount7.Consumable_order_minor__c = CreateId.id; - dataForProductCount7.Send_Date__c = null; - dataForProductCount7.Used_date__c = null; - dataForProductCount7.Lose_Flag__c = false; - dataForProductCount7.RemoveBox_No__c = 1; - orderList.add(dataForProductCount7); + System.Test.startTest(); + LexInventoryController inver = new LexInventoryController(); + LexInventoryController.init(); + List<LexInventoryController.ConsumableorderdetailsInfo> testList = LexInventoryController.consumableorderdetailsRecords; + List<LexInventoryController.ConsumableorderdetailsInfo> testList1 = new List<LexInventoryController.ConsumableorderdetailsInfo>(); + System.debug('testCount:'+testList.size()); + for(LexInventoryController.ConsumableorderdetailsInfo ass : testList){ + System.debug(ass.check); + ass.check = true; + testList1.add(ass); + } + System.debug('testList1:'+testList1); + LexInventoryController.searchConsumableorderdetails('ET','涓婃捣','Testaccount001','',JSON.serialize(testList1),20,9,'Test','ASC'); + LexInventoryController.searchConsumableorderdetails('ET','涓婃捣','Testaccount001','01210000000kUDKAA2\n10011',JSON.serialize(testList1),20,9,'Test','ASC'); + LexInventoryController.searchConsumableorderdetails('ET','涓婃捣','Testaccount001','12345678856\n1234567895\n1234567890\n12345678511\n1234567856\n1234567855\n1234567886\n12345678551\n1234567890\n1234567883\n1234567882\n1234567881\n1234567884\nn123456788412\n1234567885\n123456788512\n1234567891\n1234567892\n1234567893\n1234567894\n1001',JSON.serialize(testList1),1,0,'Test','ASC'); + LexInventoryController.save(true,JSON.serialize(testList1),myAccount1.Id,'ET',LexInventoryController.pandiandetailsMap,LexInventoryController.reSet); + LexInventoryController.searchConsumableorderdetails('ET','涓婃捣','Testaccount001','','[{"sortBy": null,"refind": 0,"ProdId": "a0l0l000004EisKAAS","Prod": {"attributes": {"type": "Product2__c","url": "/services/data/v58.0/sobjects/Product2__c/a0l0l000004EisKAAS"},"Id": "a0l0l000004EisKAAS","Name": "MH-155:鐧藉钩琛″附","Name__c": "Test07","SFDA_Status__c": "鍋滄","Packing_list_manual__c": 1,"Asset_Model_No__c": "Test07"},"Pandian": 0,"overlimitCount": 0,"orderdetails2": null,"orderdetails1": null,"limitCount": 2,"DiffReason": null,"Diff": 0,"countid": 2,"check": true,"canSelect": true,"boxPiece": "鐩�"}]',20,9,'Test','ASC'); - Consumable_order_details2__c dataForProduct = new Consumable_order_details2__c(); - dataForProduct.Bar_Code__c = '1234567894'; - dataForProduct.Sterilization_limit__c = Date.today().addDays(2); - dataForProduct.Arrive_date__c = Date.today(); - dataForProduct.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; - dataForProduct.Consumable_Product__c = proF.id; - dataForProduct.Asset_Model_No__c = proF.Asset_Model_No__c; - dataForProduct.Box_Piece__c = '涓�'; - dataForProduct.Consumable_order_minor__c = CreateId.id; - dataForProduct.Send_Date__c = null; - dataForProduct.Used_date__c = null; - dataForProduct.Lose_Flag__c = false; - dataForProduct.RemoveBox_No__c = 1; - orderList.add(dataForProduct); - Consumable_order_details2__c dataForProductCount3 = new Consumable_order_details2__c(); - dataForProductCount3.Bar_Code__c = '1234567883'; - dataForProductCount3.Sterilization_limit__c = Date.today().addDays(2); - dataForProductCount3.Arrive_date__c = Date.today(); - dataForProductCount3.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; - dataForProductCount3.Consumable_Product__c = proG.id; - dataForProductCount3.Asset_Model_No__c = proG.Asset_Model_No__c; - dataForProductCount3.Consumable_order_minor__c = CreateId.id; - dataForProductCount3.Lose_Flag__c = true; - //dataForProductCount3.RemoveBox_No__c = 1; - orderList.add(dataForProductCount3); - PageReference page = new Pagereference('/Inventory'); - page.setRedirect(true); - System.Test.setCurrentPage(page); - System.Test.startTest(); - LexInventoryController controller = new LexInventoryController(); - LexInventoryController.init(); - System.debug( - '===>鍊�1' + LexInventoryController.consumableorderdetailsRecords - ); - System.debug( - '===>鍊�2' + - JSON.serialize(LexInventoryController.consumableorderdetailsRecords) - ); - System.debug( - '===>2222222' + - JSON.serialize(LexInventoryController.consumableorderdetailsRecords) - ); - List<LexInventoryController.ConsumableorderdetailsInfo> testList = LexInventoryController.consumableorderdetailsRecords; - List<LexInventoryController.ConsumableorderdetailsInfo> testList1 = new List<LexInventoryController.ConsumableorderdetailsInfo>(); - System.debug('testCount:' + testList.size()); - for (LexInventoryController.ConsumableorderdetailsInfo ass : testList) { - System.debug(ass.check); - ass.check = true; - testList1.add(ass); - } - System.debug('testList1:' + testList1); + System.Test.stopTest(); + } + } - LexInventoryController.searchConsumableorderdetails( - 'ET', - '涓婃捣', - 'Testaccount001', - '12345678856\n1234567895\n1234567890\n12345678511\n1234567856\n1234567855\n1234567886\n12345678551\n1234567890\n1234567883\n1234567882\n1234567881\n1234567884\nn123456788412\n1234567885\n123456788512\n1234567891\n1234567892\n1234567893\n1234567894', - JSON.serialize(testList1), - 1, - 0, - 'Test', - 'ASC' - ); - System.Test.stopTest(); - } - } - static testMethod void InventoryControllerTest_xunhui() { - user MyUser_Test; - Account myAccount1; - User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; - System.runAs(thisUser) { - Profile prof1 = [ - SELECT Id - FROM Profile - WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)' - ]; - List<RecordType> rectCo = [ - SELECT Id - FROM RecordType - WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�' - ]; - if (rectCo.size() == 0) { - return; - } - StaticParameter.EscapeOrderDetail2Trigger = true; - StaticParameter.EscapeConsumableOrderDetail2Trigger = true; - RecordType rectCoO = [ - SELECT Id - FROM RecordType - WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌' - ]; - Account olympus = new Account( - RecordTypeId = rectCoO.Id, - AgentCode_Ext__c = '9999900', - Name = 'olympus' - ); - insert olympus; - myAccount1 = new Account( - name = 'Testaccount001', - Dealer_discount__c = 10, - RecordTypeId = rectCo[0].Id, - AgentCode_Ext__c = '8888888' - ); - insert myAccount1; - Contact core = new Contact( - email = 'jplumber@salesforce.com', - firstname = 'Joe', - lastname = 'Plumber', - accountid = myAccount1.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 = prof1.Id, - TimeZoneSidKey = 'Asia/Shanghai', - UserName = 'testUser@testorg.com' - ); - insert MyUser_Test; - } - System.runAs(MyUser_Test) { - Product2 prod07 = new Product2( - Name = 'Test07', - ProductCode = 'Test07', - Asset_Model_No__c = 'Test07', - SFDA_Status__c = '鏈夊姽', - Dealer_special_Object__c = true, - Packing_list_manual__c = 1, - Manual_Entry__c = false - ); - Product2 prod08 = new Product2( - Name = 'Test08', - ProductCode = 'Test08', - Asset_Model_No__c = 'Test08', - SFDA_Status__c = '鏈夊姽', - Dealer_special_Object__c = true, - Packing_list_manual__c = 1, - Manual_Entry__c = false - ); - Product2 prod09 = new Product2( - Name = 'Test09', - ProductCode = 'Test09', - Asset_Model_No__c = 'Test09', - SFDA_Status__c = '鏈夊姽', - Dealer_special_Object__c = true, - Packing_list_manual__c = 1, - Manual_Entry__c = false - ); - insert new List<Product2>{ prod07, prod08, prod09 }; + static testMethod void all(){ + user MyUser_Test; + Account myAccount1; + User thisUser = [ select Id from User where Id = :UserInfo.getUserId()]; + system.runAs(thisUser){ + Profile prof1 = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)']; + List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�']; + if (rectCo.size() == 0) { + return; + } + StaticParameter.EscapeOrderDetail2Trigger = true; + StaticParameter.EscapeConsumableOrderDetail2Trigger = true; + RecordType rectCoO = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌']; + Account olympus = new Account(RecordTypeId = rectCoO.Id, AgentCode_Ext__c = '9999900', Name = 'olympus'); + insert olympus; + myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '8888888'); + insert myAccount1; + Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.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 = prof1.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com',Work_Location__c = '涓婃捣'); + insert MyUser_Test; + } + system.runAs(MyUser_Test){ + + Product2 prod07 = new Product2(Name='Test07',ProductCode='Test07',Asset_Model_No__c = 'Test07',SFDA_Status__c = '鏈夊姽',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false); + Product2 prod08 = new Product2(Name='Test08',ProductCode='Test08',Asset_Model_No__c = 'Test08',SFDA_Status__c = '鏈夊姽',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false); + Product2 prod09 = new Product2(Name='Test09',ProductCode='Test09',Asset_Model_No__c = 'Test09',SFDA_Status__c = '鏈夊姽',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false); + insert new Product2[] {prod07,prod08,prod09}; - //鍒朵綔浜у搧 - Product2__c proG = new Product2__c( - Name = 'MH-155:鐧藉钩琛″附', - OT_CODE_Text__c = 'Test001', - Product2__c = prod07.Id - ); - insert proG; - Product2__c proH = new Product2__c( - Name = 'MB-677:BNC鐢电紗', - OT_CODE_Text__c = 'Test002', - Product2__c = prod08.Id - ); - insert proH; - Product2__c proF = new Product2__c( - Name = 'TooMAJ-643R:姘村泭闉樼003', - OT_CODE_Text__c = 'Test003', - Product2__c = prod09.Id - ); - insert proF; + //鍒朵綔浜у搧 + Product2__c proG = new Product2__c(Name='MH-155:鐧藉钩琛″附',OT_CODE_Text__c='Test001',Product2__c = prod07.Id); + insert proG; + Product2__c proH = new Product2__c(Name='MB-677:BNC鐢电紗',OT_CODE_Text__c='Test002',Product2__c = prod08.Id); + insert proH; + Product2__c proF = new Product2__c(Name='TooMAJ-643R:姘村泭闉樼003',OT_CODE_Text__c='Test003',Product2__c = prod09.Id); + insert proF; + List<Consumable_order__c> orderList = new List<Consumable_order__c>(); + //鍒拌揣 + Consumable_order__c Order1 = new Consumable_order__c(); + Order1.Name = 'OCM_01'; + Order1.Order_status__c = '鎵瑰噯'; + Order1.Order_type__c = '鍒拌揣'; + Order1.Dealer_Info__c = myAccount1.Id; + Order1.RecordTypeid = '01210000000c9dqAAA'; + Order1.Order_ProType__c = 'ET'; + orderList.add(Order1); + //鍙戣揣 + Consumable_order__c Order2 = new Consumable_order__c(); + Order2.Name = 'OCM_01'; + Order2.Order_status__c = '鎵瑰噯'; + Order2.Order_type__c = '璁㈠崟 '; + Order2.Dealer_Info__c = myAccount1.Id; + Order2.RecordTypeid = '01210000000c9drAAA'; + Order2.Order_ProType__c = 'ET'; + orderList.add(Order2); + insert orderList; + //鏌ヨ搴撳瓨 杩藉姞杩斿搧搴撳瓨 + List<Consumable_order_details2__c> conlist = new List<Consumable_order_details2__c>(); + Consumable_order_details2__c con3 = new Consumable_order_details2__c(); + con3.Arrive_date__c = Date.today(); + con3.Send_Date__c = null; + con3.Used_date__c = null; + con3.Return_date__c = null; + con3.Lose_Flag__c = false; + con3.Cancellation_Flag__c = false; + con3.Consumable_order_minor__c = Order1.id; + con3.Consumable_Arrived_order__c = Order1.id; + con3.Bar_Code__c = '1001'; + con3.Consumable_Product__c = proH.id; + conlist.add(con3); + insert conlist; - //棰勫埗澶存槑缁� - Consumable_order__c CreateId = new Consumable_order__c(); - CreateId.Name = 'testMing'; - CreateId.Order_status__c = '鑽夋涓�'; - CreateId.RecordTypeid = System.Label.RT_ConOrder_Order; - CreateId.Dealer_Info__c = myAccount1.id; - CreateId.Inventory_date__c = Date.today(); - CreateId.Order_type__c = '鐩樼偣'; - CreateId.Order_ProType__c = 'ET'; - insert CreateId; - List<Consumable_order__c> orderList = new List<Consumable_order__c>(); - //鍒拌揣 - Consumable_order__c Order1 = new Consumable_order__c(); - Order1.Name = 'OCM_01'; - Order1.Order_status__c = '鎵瑰噯'; - Order1.Order_type__c = '鍒拌揣'; - Order1.Dealer_Info__c = myAccount1.Id; - Order1.RecordTypeid = '01210000000c9dqAAA'; - Order1.Order_ProType__c = 'ENG'; - orderList.add(Order1); - //鍙戣揣 - Consumable_order__c Order2 = new Consumable_order__c(); - Order2.Name = 'OCM_01'; - Order2.Order_status__c = '鎵瑰噯'; - Order2.Order_type__c = '璁㈠崟 '; - Order2.Dealer_Info__c = myAccount1.Id; - Order2.RecordTypeid = '01210000000c9drAAA'; - Order2.Order_ProType__c = 'ENG'; - orderList.add(Order2); - insert orderList; + //productAdjust + Consumable_order_details2__c con6 = new Consumable_order_details2__c(); + // con6.Consumable_Product__c = proH.id; + con6.Lose_reason__c = '杩囨湡搴撳瓨閿�瀛�'; + // con6.Box_Piece__c = '鐩�'; + con6.Sterilization_limit__c = Date.today().addDays(-2); + con6.Bar_Code__c = '10011'; + // con6.Consumable_Arrived_order__c = Order1.id; + con6.Lose_Flag__c = true; + // con6.RecordTypeid = '01210000000kUDKAA2'; + conlist.add(con6); + System.debug('conlist===>'+conlist); + LexInventoryController.init(); + List<LexInventoryController.ConsumableorderdetailsInfo> testList = LexInventoryController.consumableorderdetailsRecords; + List<LexInventoryController.ConsumableorderdetailsInfo> testList1 = new List<LexInventoryController.ConsumableorderdetailsInfo>(); + System.debug('testCount:'+testList.size()); + for(LexInventoryController.ConsumableorderdetailsInfo ass : testList){ + System.debug(ass.check); + ass.check = true; + testList1.add(ass); + } + System.debug('testList1:'+testList1); - //鍒朵綔Consumable_order_details__c-------ProductCount - Consumable_order_details2__c dataForProductCount9 = new Consumable_order_details2__c(); - dataForProductCount9.Bar_Code__c = '1234567890'; - dataForProductCount9.Sterilization_limit__c = Date.today().addDays(2); - dataForProductCount9.Arrive_date__c = Date.today(); - dataForProductCount9.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; - dataForProductCount9.Consumable_Product__c = proG.id; - dataForProductCount9.Asset_Model_No__c = proG.Asset_Model_No__c; - dataForProductCount9.Box_Piece__c = '鐩�'; - dataForProductCount9.Consumable_order_minor__c = CreateId.id; - dataForProductCount9.Send_Date__c = null; - dataForProductCount9.Used_date__c = null; - dataForProductCount9.Lose_Flag__c = false; - dataForProductCount9.RemoveBox_No__c = 1; - insert dataForProductCount9; - - Consumable_order_details2__c dataForProductCount8 = new Consumable_order_details2__c(); - dataForProductCount8.Bar_Code__c = '1234567891'; - dataForProductCount8.Sterilization_limit__c = Date.today().addDays(2); - dataForProductCount8.Arrive_date__c = Date.today(); - dataForProductCount8.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; - dataForProductCount8.Consumable_Product__c = proG.id; - dataForProductCount8.Asset_Model_No__c = proG.Asset_Model_No__c; - dataForProductCount8.Box_Piece__c = '鐩�'; - dataForProductCount8.Consumable_order_minor__c = CreateId.id; - dataForProductCount8.Send_Date__c = null; - dataForProductCount8.Used_date__c = null; - dataForProductCount8.Lose_Flag__c = false; - dataForProductCount8.RemoveBox_No__c = 1; - insert dataForProductCount8; - - Consumable_order_details2__c dataForProductCount7 = new Consumable_order_details2__c(); - dataForProductCount7.Bar_Code__c = '1234567892'; - dataForProductCount7.Sterilization_limit__c = Date.today().addDays(2); - dataForProductCount7.Arrive_date__c = Date.today(); - dataForProductCount7.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; - dataForProductCount7.Consumable_Product__c = proH.id; - dataForProductCount7.Asset_Model_No__c = proH.Asset_Model_No__c; - dataForProductCount7.Box_Piece__c = '涓�'; - dataForProductCount7.Consumable_order_minor__c = CreateId.id; - dataForProductCount7.Send_Date__c = null; - dataForProductCount7.Used_date__c = null; - dataForProductCount7.Lose_Flag__c = false; - dataForProductCount7.RemoveBox_No__c = 1; - insert dataForProductCount7; - - Consumable_order_details2__c dataForProductCount6 = new Consumable_order_details2__c(); - dataForProductCount6.Bar_Code__c = '1234567893'; - dataForProductCount6.Sterilization_limit__c = Date.today().addDays(2); - dataForProductCount6.Arrive_date__c = Date.today(); - dataForProductCount6.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; - dataForProductCount6.Consumable_Product__c = proH.id; - dataForProductCount6.Asset_Model_No__c = proH.Asset_Model_No__c; - dataForProductCount6.Box_Piece__c = '涓�'; - dataForProductCount6.Consumable_order_minor__c = CreateId.id; - dataForProductCount6.Send_Date__c = null; - dataForProductCount6.Used_date__c = null; - dataForProductCount6.Lose_Flag__c = false; - dataForProductCount6.RemoveBox_No__c = 1; - insert dataForProductCount6; - - Consumable_order_details2__c dataForProductCount5 = new Consumable_order_details2__c(); - dataForProductCount5.Bar_Code__c = '1234567894'; - dataForProductCount5.Sterilization_limit__c = Date.today().addDays(2); - dataForProductCount5.Arrive_date__c = Date.today(); - dataForProductCount5.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; - dataForProductCount5.Consumable_Product__c = proH.id; - dataForProductCount5.Asset_Model_No__c = proH.Asset_Model_No__c; - dataForProductCount5.Box_Piece__c = '涓�'; - dataForProductCount5.Consumable_order_minor__c = CreateId.id; - dataForProductCount5.Send_Date__c = null; - dataForProductCount5.Used_date__c = null; - dataForProductCount5.Lose_Flag__c = false; - dataForProductCount5.RemoveBox_No__c = 1; - insert dataForProductCount5; - - List<Consumable_order_details2__c> conlist = new List<Consumable_order_details2__c>(); - //Barcode妫�绱� 鎵�鏈夊湪搴� - Consumable_order_details2__c con1 = new Consumable_order_details2__c(); - con1.Lose_Flag__c = false; - con1.Arrive_date__c = Date.today(); - con1.Send_Date__c = null; - con1.Return_date__c = null; - con1.Lose_Flag__c = false; - con1.Cancellation_Date__c = null; - con1.Sterilization_limit__c = Date.today().addDays(2); - con1.Bar_Code__c = '123'; - con1.Box_Piece__c = '鐩�'; - con1.Bar_Code__c = '1234567894'; - con1.Sterilization_limit__c = Date.today().addDays(2); - con1.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; - con1.Consumable_Product__c = proH.id; - con1.Consumable_order_minor__c = CreateId.id; - conlist.add(con1); - - //鏌ヨ搴撳瓨 杩藉姞杩斿搧搴撳瓨 - Consumable_order_details2__c con3 = new Consumable_order_details2__c(); - con3.Consumable_Product__c = proH.id; - con3.Bar_Code__c = '1001'; - con3.Consumable_Arrived_order__c = Order1.id; - con3.Consumable_order_minor__c = Order2.id; - con3.Arrive_date__c = Date.today(); - con3.Send_Date__c = null; - con3.Return_date__c = null; - con3.Lose_Flag__c = false; - con3.Cancellation_Flag__c = false; - con3.Consumable_order_minor__c = CreateId.id; - con3.Sterilization_limit__c = Date.today().addDays(2); - con3.Box_Piece__c = '涓�'; - con3.RecordTypeid = '01210000000kUDKAA2'; - conlist.add(con3); - - //productAdjust - Consumable_order_details2__c con6 = new Consumable_order_details2__c(); - con6.Consumable_Product__c = proH.id; - con6.Lose_reason__c = '杩囨湡搴撳瓨閿�瀛�'; - con6.Box_Piece__c = '鐩�'; - con6.Sterilization_limit__c = Date.today().addDays(-2); - con6.Bar_Code__c = '10011'; - con6.Consumable_Arrived_order__c = Order1.id; - con6.Lose_Flag__c = true; - con6.RecordTypeid = '01210000000kUDKAA2'; - conlist.add(con6); - System.debug('conlist===>' + conlist); - - //reset592 - Consumable_order_details2__c con4 = new Consumable_order_details2__c(); - con4.Arrive_date__c = Date.today(); - con4.Send_Date__c = null; - con4.Return_date__c = null; - con4.Lose_Flag__c = false; - con4.Cancellation_Date__c = null; - con4.Sterilization_limit__c = Date.today().addDays(2); - con4.Bar_Code__c = '123456'; - con4.Box_Piece__c = '鐩�'; - // con2.Bar_Code__c = '1234567894'; - con4.Sterilization_limit__c = Date.today().addDays(2); - con4.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; - con4.Consumable_Product__c = proH.id; - // con2.Asset_Model_No__c = proH.Asset_Model_No__c; - con4.Consumable_order_minor__c = CreateId.id; - conlist.add(con4); - - //鏌ヨ搴撳瓨 杩藉姞杩斿搧搴撳瓨 - Consumable_order_details2__c con5 = new Consumable_order_details2__c(); - con5.Arrive_date__c = Date.today(); - con5.Send_Date__c = null; - con5.Return_date__c = null; - con5.Lose_Flag__c = false; - con5.Cancellation_Flag__c = false; - con5.Consumable_Product__c = proH.id; - con5.Consumable_order_minor__c = Order2.id; - // con5.Sterilization_limit__c = Date.today().addDays(2); - con5.Box_Piece__c = '鐩�'; - con5.Bar_Code__c = '1001'; - conlist.add(con5); - insert conlist; - - System.Test.startTest(); - LexInventoryController inver = new LexInventoryController(); - LexInventoryController.init(); - List<LexInventoryController.ConsumableorderdetailsInfo> testList = LexInventoryController.consumableorderdetailsRecords; - List<LexInventoryController.ConsumableorderdetailsInfo> testList1 = new List<LexInventoryController.ConsumableorderdetailsInfo>(); - System.debug('testCount:' + testList.size()); - for (LexInventoryController.ConsumableorderdetailsInfo ass : testList) { - System.debug(ass.check); - ass.check = true; - testList1.add(ass); - } - System.debug('testList1:' + testList1); - LexInventoryController.searchConsumableorderdetails( - 'ET', - '涓婃捣', - 'Testaccount001', - '', - JSON.serialize(testList1), - 20, - 9, - 'Test', - 'ASC' - ); - LexInventoryController.searchConsumableorderdetails( - 'ET', - '涓婃捣', - 'Testaccount001', - '01210000000kUDKAA2\n10011', - JSON.serialize(testList1), - 20, - 9, - 'Test', - 'ASC' - ); - LexInventoryController.searchConsumableorderdetails( - 'ET', - '涓婃捣', - 'Testaccount001', - '12345678856\n1234567895\n1234567890\n12345678511\n1234567856\n1234567855\n1234567886\n12345678551\n1234567890\n1234567883\n1234567882\n1234567881\n1234567884\nn123456788412\n1234567885\n123456788512\n1234567891\n1234567892\n1234567893\n1234567894\n1001', - JSON.serialize(testList1), - 1, - 0, - 'Test', - 'ASC' - ); - LexInventoryController.save( - true, - JSON.serialize(testList1), - myAccount1.Id, - 'ET', - LexInventoryController.pandiandetailsMap, - LexInventoryController.reSet - ); - LexInventoryController.searchConsumableorderdetails( - 'ET', - '涓婃捣', - 'Testaccount001', - '', - '[{"sortBy": null,"refind": 0,"ProdId": "a0l0l000004EisKAAS","Prod": {"attributes": {"type": "Product2__c","url": "/services/data/v58.0/sobjects/Product2__c/a0l0l000004EisKAAS"},"Id": "a0l0l000004EisKAAS","Name": "MH-155:鐧藉钩琛″附","Name__c": "Test07","SFDA_Status__c": "鍋滄","Packing_list_manual__c": 1,"Asset_Model_No__c": "Test07"},"Pandian": 0,"overlimitCount": 0,"orderdetails2": null,"orderdetails1": null,"limitCount": 2,"DiffReason": null,"Diff": 0,"countid": 2,"check": true,"canSelect": true,"boxPiece": "鐩�"}]', - 20, - 9, - 'Test', - 'ASC' - ); - - System.Test.stopTest(); - } - } - - static testMethod void all() { - user MyUser_Test; - Account myAccount1; - User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; - System.runAs(thisUser) { - Profile prof1 = [ - SELECT Id - FROM Profile - WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)' - ]; - List<RecordType> rectCo = [ - SELECT Id - FROM RecordType - WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�' - ]; - if (rectCo.size() == 0) { - return; - } - StaticParameter.EscapeOrderDetail2Trigger = true; - StaticParameter.EscapeConsumableOrderDetail2Trigger = true; - RecordType rectCoO = [ - SELECT Id - FROM RecordType - WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌' - ]; - Account olympus = new Account( - RecordTypeId = rectCoO.Id, - AgentCode_Ext__c = '9999900', - Name = 'olympus' - ); - insert olympus; - myAccount1 = new Account( - name = 'Testaccount001', - Dealer_discount__c = 10, - RecordTypeId = rectCo[0].Id, - AgentCode_Ext__c = '8888888' - ); - insert myAccount1; - Contact core = new Contact( - email = 'jplumber@salesforce.com', - firstname = 'Joe', - lastname = 'Plumber', - accountid = myAccount1.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 = prof1.Id, - TimeZoneSidKey = 'Asia/Shanghai', - UserName = 'testUser@testorg.com', - Work_Location__c = '涓婃捣' - ); - insert MyUser_Test; - } - System.runAs(MyUser_Test) { - Product2 prod07 = new Product2( - Name = 'Test07', - ProductCode = 'Test07', - Asset_Model_No__c = 'Test07', - SFDA_Status__c = '鏈夊姽', - Dealer_special_Object__c = true, - Packing_list_manual__c = 1, - Manual_Entry__c = false - ); - Product2 prod08 = new Product2( - Name = 'Test08', - ProductCode = 'Test08', - Asset_Model_No__c = 'Test08', - SFDA_Status__c = '鏈夊姽', - Dealer_special_Object__c = true, - Packing_list_manual__c = 1, - Manual_Entry__c = false - ); - Product2 prod09 = new Product2( - Name = 'Test09', - ProductCode = 'Test09', - Asset_Model_No__c = 'Test09', - SFDA_Status__c = '鏈夊姽', - Dealer_special_Object__c = true, - Packing_list_manual__c = 1, - Manual_Entry__c = false - ); - insert new List<Product2>{ prod07, prod08, prod09 }; - - //鍒朵綔浜у搧 - Product2__c proG = new Product2__c( - Name = 'MH-155:鐧藉钩琛″附', - OT_CODE_Text__c = 'Test001', - Product2__c = prod07.Id - ); - insert proG; - Product2__c proH = new Product2__c( - Name = 'MB-677:BNC鐢电紗', - OT_CODE_Text__c = 'Test002', - Product2__c = prod08.Id - ); - insert proH; - Product2__c proF = new Product2__c( - Name = 'TooMAJ-643R:姘村泭闉樼003', - OT_CODE_Text__c = 'Test003', - Product2__c = prod09.Id - ); - insert proF; - List<Consumable_order__c> orderList = new List<Consumable_order__c>(); - //鍒拌揣 - Consumable_order__c Order1 = new Consumable_order__c(); - Order1.Name = 'OCM_01'; - Order1.Order_status__c = '鎵瑰噯'; - Order1.Order_type__c = '鍒拌揣'; - Order1.Dealer_Info__c = myAccount1.Id; - Order1.RecordTypeid = '01210000000c9dqAAA'; - Order1.Order_ProType__c = 'ET'; - orderList.add(Order1); - //鍙戣揣 - Consumable_order__c Order2 = new Consumable_order__c(); - Order2.Name = 'OCM_01'; - Order2.Order_status__c = '鎵瑰噯'; - Order2.Order_type__c = '璁㈠崟 '; - Order2.Dealer_Info__c = myAccount1.Id; - Order2.RecordTypeid = '01210000000c9drAAA'; - Order2.Order_ProType__c = 'ET'; - orderList.add(Order2); - insert orderList; - //鏌ヨ搴撳瓨 杩藉姞杩斿搧搴撳瓨 - List<Consumable_order_details2__c> conlist = new List<Consumable_order_details2__c>(); - Consumable_order_details2__c con3 = new Consumable_order_details2__c(); - con3.Arrive_date__c = Date.today(); - con3.Send_Date__c = null; - con3.Used_date__c = null; - con3.Return_date__c = null; - con3.Lose_Flag__c = false; - con3.Cancellation_Flag__c = false; - con3.Consumable_order_minor__c = Order1.id; - con3.Consumable_Arrived_order__c = Order1.id; - con3.Bar_Code__c = '1001'; - con3.Consumable_Product__c = proH.id; - conlist.add(con3); - insert conlist; - - //productAdjust - Consumable_order_details2__c con6 = new Consumable_order_details2__c(); - // con6.Consumable_Product__c = proH.id; - con6.Lose_reason__c = '杩囨湡搴撳瓨閿�瀛�'; - // con6.Box_Piece__c = '鐩�'; - con6.Sterilization_limit__c = Date.today().addDays(-2); - con6.Bar_Code__c = '10011'; - // con6.Consumable_Arrived_order__c = Order1.id; - con6.Lose_Flag__c = true; - // con6.RecordTypeid = '01210000000kUDKAA2'; - conlist.add(con6); - System.debug('conlist===>' + conlist); - LexInventoryController.init(); - List<LexInventoryController.ConsumableorderdetailsInfo> testList = LexInventoryController.consumableorderdetailsRecords; - List<LexInventoryController.ConsumableorderdetailsInfo> testList1 = new List<LexInventoryController.ConsumableorderdetailsInfo>(); - System.debug('testCount:' + testList.size()); - for (LexInventoryController.ConsumableorderdetailsInfo ass : testList) { - System.debug(ass.check); - ass.check = true; - testList1.add(ass); - } - System.debug('testList1:' + testList1); - - LexInventoryController.searchConsumableorderdetails( - 'ET', - '涓婃捣', - 'Testaccount001', - '1001\n10011', - JSON.serialize(testList1), - 20, - 9, - 'Test', - 'ASC' - ); - LexInventoryController.searchConsumableorderdetails( - 'ET', - '涓婃捣', - 'Testaccount001', - '', - JSON.serialize(testList1), - 20, - 9, - 'Test', - 'ASC' - ); - } - } -} + LexInventoryController.searchConsumableorderdetails('ET','涓婃捣','Testaccount001','1001\n10011',JSON.serialize(testList1),20,9,'Test','ASC'); + LexInventoryController.searchConsumableorderdetails('ET','涓婃捣','Testaccount001','',JSON.serialize(testList1),20,9,'Test','ASC'); + } + } +} \ No newline at end of file -- Gitblit v1.9.1