// TODO EquipmentSetDailyBatchSchedule.test
|
@isTest
|
private class EquipmentSetDailyBatchTEST {
|
final static Integer okStatus = 99;
|
|
@isTest static void test_method_one() {
|
// システム管理者
|
User user_admin = new User(Test_staff__c = true);
|
user_admin.LastName = '_サンブリッジ';
|
user_admin.FirstName = 'う';
|
user_admin.Alias = 'う';
|
user_admin.Email = 'olympusTest03@sunbridge.com';
|
user_admin.Username = 'olympusTest03@sunbridge.com';
|
user_admin.CommunityNickname = 'う';
|
user_admin.IsActive = true;
|
user_admin.EmailEncodingKey = 'ISO-2022-JP';
|
user_admin.TimeZoneSidKey = 'Asia/Tokyo';
|
user_admin.LocaleSidKey = 'ja_JP';
|
user_admin.LanguageLocaleKey = 'ja';
|
user_admin.ProfileId = System.Label.ProfileId_SystemAdmin;
|
user_admin.Province__c = '北京';
|
user_admin.Dept__c = '医疗华北营业本部';
|
user_admin.Use_Start_Date__c = Date.today().addMonths(-6);
|
insert user_admin;
|
|
System.runAs(user_admin) {
|
|
StaticParameter.EscapeNFM001AgencyContractTrigger = true;
|
ControllerUtil.EscapeNFM001Trigger = true;
|
Oly_TriggerHandler.bypass('AssetHandler');
|
Oly_TriggerHandler.bypass('PowerBIBaseHandler');
|
Oly_TriggerHandler.bypass('AgencyOppUpdHandler');
|
Oly_TriggerHandler.bypass('UpdateContractAimAmountHandler');
|
//Profile prof = [select Id from Profile where Name ='系统管理员'];
|
// 病院を作る
|
Account hospital = new Account();
|
hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
|
hospital.Name = 'test hospital';
|
insert hospital;
|
// 产品
|
Product2 pro1 = new Product2(Name='name01',IsActive=true,Family='GI',Asset_Model_No__c='n01',Serial_Lot_No__c='S/N tracing',ProductCode_Ext__c='pc01',Manual_Entry__c=false);
|
Product2 pro2 = new Product2(Name='name02',IsActive=true,Family='GI',Asset_Model_No__c='n02',Serial_Lot_No__c='Lot tracing',ProductCode_Ext__c='pc02',Manual_Entry__c=false);
|
Product2 pro3 = new Product2(Name='name03',IsActive=true,Family='GI',Asset_Model_No__c='n03',Serial_Lot_No__c='S/N tracing',ProductCode_Ext__c='pc03',Manual_Entry__c=false);
|
insert new Product2[] {pro1, pro2, pro3};
|
RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
|
//创建用户
|
user MyUser_Test = [select id,name from user where name =:'SB 葛'];
|
// 戦略科室を得る
|
Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
|
// 診療科を作る
|
Account dep = new Account();
|
dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
|
dep.Name = 'test dep';
|
dep.AgentCode_Ext__c = '9999998';
|
dep.ParentId = strategicDep[0].Id;
|
dep.Department_Class__c = strategicDep[0].Id;
|
dep.Hospital__c = hospital.Id;
|
insert dep;
|
|
Contact contact2 = new Contact();
|
contact2.AccountId = dep.Id;
|
contact2.FirstName = '責任者';
|
contact2.LastName = 'test1经销商';
|
insert contact2;
|
|
// 资产
|
Asset asset1 = new Asset(Asset_Owner__c = 'Olympus');
|
asset1.RecordTypeId = System.Label.Asset_RecordType;
|
asset1.SerialNumber = 'ass01';
|
asset1.Name = 'ass01';
|
asset1.AccountId = dep.Id;
|
asset1.Department_Class__c = strategicDep[0].Id;
|
asset1.Hospital__c = hospital.Id;
|
asset1.Product2Id = pro1.Id;
|
asset1.Quantity = 1;
|
asset1.Manage_type__c = '个体管理';
|
|
Asset asset2 = new Asset(Asset_Owner__c = 'Olympus');
|
asset2.RecordTypeId = System.Label.Asset_RecordType;
|
asset2.SerialNumber = 'ass02';
|
asset2.Loaner_accsessary__c = true;
|
asset2.Name = 'ass02';
|
asset2.AccountId = dep.Id;
|
asset2.Department_Class__c = strategicDep[0].Id;
|
asset2.Hospital__c = hospital.Id;
|
asset2.Quantity = 1;
|
asset2.Product2Id = pro2.Id;
|
|
Asset asset3 = new Asset(Asset_Owner__c = 'Olympus');
|
asset3.RecordTypeId = System.Label.Asset_RecordType;
|
asset3.SerialNumber = 'ass03';
|
asset3.Loaner_accsessary__c = true;
|
asset3.Name = 'ass03';
|
asset3.AccountId = dep.Id;
|
asset3.Department_Class__c = strategicDep[0].Id;
|
asset3.Hospital__c = hospital.Id;
|
asset3.Quantity = 1;
|
asset3.Product2Id = pro3.Id;
|
insert new Asset[] {asset1, asset2,asset3};
|
|
Opportunity opp1 = new Opportunity(
|
Name='testOpp1',
|
StageName='引合',
|
CloseDate=Date.today(),
|
AccountId=dep.Id,
|
Competitor__c ='A',
|
Click_Close_Date__c = null,
|
RecordType = rectOpp
|
);
|
Opportunity opp2 = new Opportunity(
|
Name='testOpp1',
|
StageName='引合',
|
CloseDate=Date.today(),
|
AccountId=dep.Id,
|
Sales_Root__c = 'OCM直接販売',
|
Competitor__c ='A',
|
Click_Close_Date__c = null,
|
RecordType = rectOpp
|
);
|
insert new Opportunity[] {opp2, opp1};
|
//注残
|
Statu_Achievements__c Sac = new Statu_Achievements__c(
|
name = 'zhucan_one',
|
Opportunity__c = opp2.id,
|
DeliveryDate__c = Date.today(),
|
ContractAmount__c = 0
|
);
|
insert Sac;
|
Test.startTest();
|
// 修理を作成する01
|
Repair__c repair01 = new Repair__c();
|
repair01.Account__c = dep.Id;
|
repair01.Department_Class__c = strategicDep[0].Id;
|
repair01.Hospital__c = hospital.Id;
|
repair01.Delivered_Product__c = asset1.Id;
|
repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays( -11); // 维修合同判断日がサービス契約開始日の前日
|
repair01.Repair_Start_Date__c = Date.today().addDays(-9);
|
repair01.Repair_Final_Inspection_Date__c = null;
|
repair01.Repair_Ordered_Date__c = Date.today();
|
repair01.SAP_Transfer_time__c = Date.today();
|
insert repair01;
|
|
//新建备品借出申请-普通
|
OPDPlan__c oPDPlan = new OPDPlan__c();
|
oPDPlan.Status__c = '计划中';
|
oPDPlan.OPDPlan_ImplementDate__c = Date.today().addDays(+12);
|
oPDPlan.NoOpp_Reason__c = 'HCP对应';
|
oPDPlan.OPDType__c='科室';
|
insert oPDPlan;
|
//新建备品借出申请-已购待货
|
Rental_Apply__c raObj = new Rental_Apply__c();
|
raObj.Name='*';
|
raObj.Product_category__c = 'GI';
|
raObj.Person_In_Charge__c = user_admin.id;
|
raObj.applyUser__c = user_admin.id;
|
raObj.Hospital__c = hospital.Id;//医院
|
raObj.Strategic_dept__c = strategicDep[0].id;//战略科室
|
raObj.Demo_purpose1__c = '产品试用';
|
raObj.demo_purpose2__c ='已购待货';
|
raObj.Demo_purpose_text__c ='测试用的备品借出申请';
|
raObj.Request_shipping_day__c = Date.today() + 5;
|
// raObj.Hope_Lonaer_date_Num__c = 16; // 希望借用天数
|
raObj.Loaner_received_staff__c = '测试用户';
|
raObj.Loaner_received_staff_phone__c = '13700008';
|
raObj.direct_send__c = '上门自提';
|
raObj.Repair__c = repair01.id;
|
raObj.Statu_Achievements__c = Sac.id;
|
raObj.Account__c = dep.id;//科室
|
raObj.Follow_UP_Opp__c = opp2.Id;
|
raObj.pickup_time__c = Datetime.now()+8;
|
raObj.direct_shippment_address__c = '233333的地址';
|
raObj.Phone_number__c = '1234567890';
|
raObj.Loaner_medical_Staff__c = contact2.Id;
|
raObj.OPDPlan__c = oPDPlan.Id;
|
raObj.Status__c ='草案中';
|
//新建备品借出申请-已购待货
|
Rental_Apply__c raObj1 = new Rental_Apply__c();
|
raObj1.Name='*';
|
raObj1.Product_category__c = 'GI';
|
raObj1.Person_In_Charge__c = user_admin.id;
|
raObj1.applyUser__c = user_admin.id;
|
raObj1.Hospital__c = hospital.Id;//医院
|
raObj1.Strategic_dept__c = strategicDep[0].id;//战略科室
|
raObj1.Demo_purpose1__c = '维修代用';
|
raObj1.demo_purpose2__c ='保修用户';
|
raObj1.Demo_purpose_text__c ='测试用的备品借出申请';
|
raObj1.Request_shipping_day__c = Date.today() + 5;
|
// raObj1.Hope_Lonaer_date_Num__c = 16;
|
raObj1.Loaner_received_staff__c = '测试用户';
|
raObj1.Loaner_received_staff_phone__c = '13700008';
|
raObj1.direct_send__c = '上门自提';
|
raObj1.Repair__c = repair01.id;
|
raObj1.Account__c = dep.id;//科室
|
raObj1.Follow_UP_Opp__c = opp1.Id;
|
raObj1.pickup_time__c = Datetime.now()+8;
|
raObj1.direct_shippment_address__c = '233333的地址';
|
raObj1.Phone_number__c = '1234567890';
|
raObj1.Loaner_medical_Staff__c = contact2.Id;
|
raObj1.OPDPlan__c = oPDPlan.Id;
|
raObj1.Status__c ='草案中';
|
try {
|
insert new Rental_Apply__c[]{raObj,raObj1} ;
|
} catch (Exception e) {
|
System.debug('Exception---' + e);
|
} /**
|
//repair01.Repair_Shipped_Date__c = Date.today().addDays(-14);
|
//update repair01;
|
Rental_Apply_Equipment_Set__c DemoSetLine3 = new Rental_Apply_Equipment_Set__c();
|
DemoSetLine3.Rental_Apply__c = raObj.id;
|
DemoSetLine3.IndexFromUniqueKey__c = 1;
|
DemoSetLine3.UniqueKey__c = '1:1';
|
DemoSetLine3.DataMigration_Flag__c =true;
|
Rental_Apply_Equipment_Set__c DemoSetLine4 = new Rental_Apply_Equipment_Set__c();
|
DemoSetLine4.Rental_Apply__c = raObj1.id;
|
DemoSetLine4.IndexFromUniqueKey__c = 2;
|
DemoSetLine4.UniqueKey__c = '1:2';
|
DemoSetLine4.Rental_End_Date__c = Date.today();
|
DemoSetLine4.DataMigration_Flag__c =true;
|
DemoSetLine3.Shippment_loaner_time__c = System.now().addDays(-10);
|
insert new Rental_Apply_Equipment_Set__c[]{DemoSetLine3,DemoSetLine4};
|
**/
|
//System.assertEquals(RaesList[0].Final_reply_day__c ,Date.today());
|
id execBTId = Database.executeBatch(new EquipmentSetDailyBatch(null), 20);
|
Test.stopTest();
|
}
|
}
|
|
@isTest static void test_method_Two() {
|
// システム管理者
|
User user_admin = new User(Test_staff__c = true);
|
user_admin.LastName = '_サンブリッジ';
|
user_admin.FirstName = 'う';
|
user_admin.Alias = 'う';
|
user_admin.Email = 'olympusTest03@sunbridge.com';
|
user_admin.Username = 'olympusTest03@sunbridge.com';
|
user_admin.CommunityNickname = 'う';
|
user_admin.IsActive = true;
|
user_admin.EmailEncodingKey = 'ISO-2022-JP';
|
user_admin.TimeZoneSidKey = 'Asia/Tokyo';
|
user_admin.LocaleSidKey = 'ja_JP';
|
user_admin.LanguageLocaleKey = 'ja';
|
user_admin.ProfileId = System.Label.ProfileId_SystemAdmin;
|
user_admin.Province__c = '北京';
|
user_admin.Dept__c = '医疗华北营业本部';
|
user_admin.Use_Start_Date__c = Date.today().addMonths(-6);
|
insert user_admin;
|
|
System.runAs(user_admin) {
|
StaticParameter.EscapeNFM001AgencyContractTrigger = true;
|
ControllerUtil.EscapeNFM001Trigger = true;
|
Oly_TriggerHandler.bypass('AssetHandler');
|
Oly_TriggerHandler.bypass('PowerBIBaseHandler');
|
Oly_TriggerHandler.bypass('AgencyOppUpdHandler');
|
Oly_TriggerHandler.bypass('UpdateContractAimAmountHandler');
|
//Profile prof = [select Id from Profile where Name ='系统管理员'];
|
// 病院を作る
|
Account hospital = new Account();
|
hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
|
hospital.Name = 'test hospital';
|
insert hospital;
|
// 产品
|
Product2 pro1 = new Product2(Name='name01',IsActive=true,Family='GI',Asset_Model_No__c='n01',Serial_Lot_No__c='S/N tracing',ProductCode_Ext__c='pc01',Manual_Entry__c=false);
|
Product2 pro2 = new Product2(Name='name02',IsActive=true,Family='GI',Asset_Model_No__c='n02',Serial_Lot_No__c='Lot tracing',ProductCode_Ext__c='pc02',Manual_Entry__c=false);
|
Product2 pro3 = new Product2(Name='name03',IsActive=true,Family='GI',Asset_Model_No__c='n03',Serial_Lot_No__c='S/N tracing',ProductCode_Ext__c='pc03',Manual_Entry__c=false);
|
insert new Product2[] {pro1, pro2, pro3};
|
RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
|
//创建用户
|
user MyUser_Test = [select id,name from user where name =:'SB 葛'];
|
// 戦略科室を得る
|
Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
|
// 診療科を作る
|
Account dep = new Account();
|
dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
|
dep.Name = 'test dep';
|
dep.AgentCode_Ext__c = '9999998';
|
dep.ParentId = strategicDep[0].Id;
|
dep.Department_Class__c = strategicDep[0].Id;
|
dep.Hospital__c = hospital.Id;
|
insert dep;
|
|
Contact contact2 = new Contact();
|
contact2.AccountId = dep.Id;
|
contact2.FirstName = '責任者';
|
contact2.LastName = 'test1经销商';
|
insert contact2;
|
|
// 资产
|
Asset asset1 = new Asset(Asset_Owner__c = 'Olympus');
|
asset1.RecordTypeId = System.Label.Asset_RecordType;
|
asset1.SerialNumber = 'ass01';
|
asset1.Name = 'ass01';
|
asset1.AccountId = dep.Id;
|
asset1.Department_Class__c = strategicDep[0].Id;
|
asset1.Hospital__c = hospital.Id;
|
asset1.Product2Id = pro1.Id;
|
asset1.Quantity = 1;
|
asset1.Manage_type__c = '个体管理';
|
|
Asset asset2 = new Asset(Asset_Owner__c = 'Olympus');
|
asset2.RecordTypeId = System.Label.Asset_RecordType;
|
asset2.SerialNumber = 'ass02';
|
asset2.Loaner_accsessary__c = true;
|
asset2.Name = 'ass02';
|
asset2.AccountId = dep.Id;
|
asset2.Department_Class__c = strategicDep[0].Id;
|
asset2.Hospital__c = hospital.Id;
|
asset2.Quantity = 1;
|
asset2.Product2Id = pro2.Id;
|
|
Asset asset3 = new Asset(Asset_Owner__c = 'Olympus');
|
asset3.RecordTypeId = System.Label.Asset_RecordType;
|
asset3.SerialNumber = 'ass03';
|
asset3.Loaner_accsessary__c = true;
|
asset3.Name = 'ass03';
|
asset3.AccountId = dep.Id;
|
asset3.Department_Class__c = strategicDep[0].Id;
|
asset3.Hospital__c = hospital.Id;
|
asset3.Quantity = 1;
|
asset3.Product2Id = pro3.Id;
|
insert new Asset[] {asset1, asset2,asset3};
|
Opportunity opp1 = new Opportunity(
|
Name='testOpp1',
|
StageName='引合',
|
CloseDate=Date.today(),
|
AccountId=dep.Id,
|
Competitor__c ='A',
|
Click_Close_Date__c = null,
|
RecordType = rectOpp
|
);
|
OPDPlan__c oPDPlan = new OPDPlan__c();
|
oPDPlan.Status__c = '计划中';
|
oPDPlan.OPDPlan_ImplementDate__c = Date.today().addDays(+12);
|
oPDPlan.NoOpp_Reason__c = 'HCP对应';
|
oPDPlan.OPDType__c='科室';
|
insert oPDPlan;
|
|
// 修理を作成する01
|
Repair__c repair01 = new Repair__c();
|
repair01.Account__c = dep.Id;
|
repair01.Department_Class__c = strategicDep[0].Id;
|
repair01.Hospital__c = hospital.Id;
|
repair01.Delivered_Product__c = asset1.Id;
|
repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays( -11); // 维修合同判断日がサービス契約開始日の前日
|
repair01.Repair_Start_Date__c = Date.today().addDays(-9);
|
repair01.Repair_Final_Inspection_Date__c = null;
|
repair01.Repair_Ordered_Date__c = Date.today();
|
|
insert repair01;
|
|
//新建备品借出申请-普通
|
Rental_Apply__c raObj = new Rental_Apply__c();
|
raObj.Name='*';
|
raObj.Product_category__c = 'GI';
|
raObj.Person_In_Charge__c = user_admin.id;
|
raObj.applyUser__c = user_admin.id;
|
raObj.Hospital__c = hospital.Id;//医院
|
raObj.Strategic_dept__c = strategicDep[0].id;//战略科室
|
raObj.Demo_purpose1__c = '产品试用';
|
raObj.demo_purpose2__c ='试用(无询价)';
|
raObj.Demo_purpose_text__c ='测试用的备品借出申请';
|
raObj.Request_shipping_day__c = Date.today() + 5;
|
raObj.Hope_Lonaer_date_Num__c = 16;
|
raObj.Loaner_received_staff__c = '测试用户';
|
raObj.Loaner_received_staff_phone__c = '13700008';
|
raObj.direct_send__c = '上门自提';
|
raObj.Repair__c = repair01.id;
|
raObj.Account__c = dep.id;//科室
|
raObj.Follow_UP_Opp__c = opp1.Id;
|
raObj.pickup_time__c = Datetime.now()+8;
|
raObj.direct_shippment_address__c = '233333的地址';
|
raObj.Phone_number__c = '1234567890';
|
raObj.Loaner_medical_Staff__c = contact2.Id;
|
raObj.OPDPlan__c = oPDPlan.Id;
|
insert raObj;
|
Rental_Apply_Equipment_Set__c DemoSetLine = new Rental_Apply_Equipment_Set__c();
|
DemoSetLine.Rental_Apply__c = raObj.id;
|
DemoSetLine.IndexFromUniqueKey__c = 1;
|
DemoSetLine.UniqueKey__c = '1:1';
|
Rental_Apply_Equipment_Set__c DemoSetLine2 = new Rental_Apply_Equipment_Set__c();
|
DemoSetLine2.Rental_Apply__c = raObj.id;
|
DemoSetLine2.IndexFromUniqueKey__c = 2;
|
DemoSetLine2.UniqueKey__c = '1:2';
|
|
insert new Rental_Apply_Equipment_Set__c[]{DemoSetLine, DemoSetLine2};
|
//bp2 //备品set@出库
|
// Equipment_Set__c equipmentSet1 = new Equipment_Set__c();
|
// equipmentSet1.Name = 'SetTest-001';
|
// equipmentSet1.CurrencyIsoCode = 'CNY';
|
// equipmentSet1.Loaner_code__c = '备品Set01';//備品型番
|
// equipmentSet1.SerialNumber__c = '00009901';//机身编号
|
// equipmentSet1.Shipment_request_time__c = System.now();//出库指示时间
|
// equipmentSet1.Arrival_in_wh__c = false;//回库确认
|
// //equipmentSet1.Arrival_wh_time2__c= System.now();
|
// equipmentSet1.Loaner_name__c = '备品set01Name';//備品名称
|
// equipmentSet1.Product_category__c = 'SP';//产品分类(GI/SP)
|
// equipmentSet1.Loaner_category__c ='主机';//备品类型
|
// equipmentSet1.Equipment_Type__c = '促销用';//备品分类
|
// equipmentSet1.Salesdepartment__c ='1.华北营业本部';//所在地区(本部)
|
// equipmentSet1.Last_Reserve_Rental_Apply_Equipment_Set__c = DemoSetLine.id;//最新备品申请借出历史
|
// equipmentSet1.Pre_Reserve_Rental_Apply_Equipment_Set__c =DemoSetLine2.id; //上次备品申请借出历史
|
// //equipmentSet1.Shippment_loaner_time__c = Date.today();
|
// insert equipmentSet1;
|
|
// //备品set明细
|
// Equipment_Set_Detail__c equipmentSetDetail1 = new Equipment_Set_Detail__c();
|
// equipmentSetDetail1.Name = '备品set明细01';
|
// equipmentSetDetail1.Equipment_Set__c = equipmentSet1.Id;
|
// equipmentSetDetail1.Asset__c = asset1.Id;
|
// equipmentSetDetail1.CurrencyIsoCode = 'CNY';
|
// equipmentSetDetail1.Select_rental__c = true;
|
// equipmentSetDetail1.Active_judgement_text__c = okStatus;
|
// equipmentSetDetail1.Select_rental__c = true;
|
|
// Equipment_Set_Detail__c equipmentSetDetail2 = new Equipment_Set_Detail__c();
|
// equipmentSetDetail2.Name = '备品set明细02';
|
// equipmentSetDetail2.Equipment_Set__c = equipmentSet1.Id;
|
// equipmentSetDetail2.Asset__c = asset2.Id;
|
// equipmentSetDetail2.Select_rental__c =true;
|
// equipmentSetDetail2.CurrencyIsoCode = 'CNY';
|
// equipmentSetDetail2.Active_judgement_text__c = okStatus;
|
// equipmentSetDetail2.Select_rental__c = true;
|
|
// insert new Equipment_Set_Detail__c[] {equipmentSetDetail1, equipmentSetDetail2};
|
|
// //备品set入库
|
// Equipment_Set__c equipmentSetIn = new Equipment_Set__c();
|
// equipmentSetIn.Name = '备品set入库';
|
// equipmentSetIn.CurrencyIsoCode = 'CNY';
|
// equipmentSetIn.Loaner_code__c = '备品set02';
|
// equipmentSetIn.Loaner_name__c = '备品set02Name';
|
// equipmentSetIn.Product_category__c = 'SP';
|
// equipmentSetIn.Loaner_category__c ='主机';
|
// equipmentSetIn.Equipment_Type__c = '促销用';
|
// equipmentSetIn.Salesdepartment__c ='1.华北营业本部';
|
// equipmentSetIn.Last_Reserve_Rental_Apply_Equipment_Set__c = DemoSetLine.id;
|
// equipmentSetIn.Pre_Reserve_Rental_Apply_Equipment_Set__c =DemoSetLine2.id;
|
// equipmentSetIn.Shipment_request_time__c = Date.today();
|
// equipmentSetIn.Shippment_loaner_time__c = Date.today();
|
// insert equipmentSetIn;
|
|
// Equipment_Set_Detail__c equipmentSetDetailIn_1 = new Equipment_Set_Detail__c();
|
// equipmentSetDetailIn_1.Name = '备品set明细011';
|
// equipmentSetDetailIn_1.Equipment_Set__c = equipmentSetIn.Id;
|
// equipmentSetDetailIn_1.Asset__c = asset2.Id;
|
// equipmentSetDetailIn_1.CurrencyIsoCode = 'CNY';
|
// equipmentSetDetailIn_1.Active_judgement_text__c = okStatus;
|
// equipmentSetDetailIn_1.Select_rental__c = true;
|
|
// Equipment_Set_Detail__c equipmentSetDetailIn_2 = new Equipment_Set_Detail__c();
|
// equipmentSetDetailIn_2.Name = '备品set明细022';
|
// equipmentSetDetailIn_2.Equipment_Set__c = equipmentSetIn.Id;
|
// equipmentSetDetailIn_2.Asset__c = asset2.Id;
|
// equipmentSetDetailIn_2.CurrencyIsoCode = 'CNY';
|
// equipmentSetDetailIn_2.Active_judgement_text__c = okStatus;
|
// equipmentSetDetailIn_2.Select_rental__c = true;
|
|
// insert new Equipment_Set_Detail__c[] {equipmentSetDetailIn_1, equipmentSetDetailIn_2};
|
|
// //备品各种Error
|
// //备品没有出库指示
|
// Equipment_Set__c equipmentSetInError = new Equipment_Set__c();
|
// equipmentSetInError.Name = '备品set不能出库';
|
// equipmentSetInError.CurrencyIsoCode = 'CNY';
|
// equipmentSetInError.Loaner_code__c = '备品set02';
|
// equipmentSetInError.Arrival_in_wh__c = false;
|
// equipmentSetInError.Loaner_name__c = '备品set02Name';
|
// equipmentSetInError.Product_category__c = 'GI';
|
// equipmentSetInError.Loaner_category__c ='主机';
|
// equipmentSetInError.Equipment_Type__c = '促销用';
|
// equipmentSetInError.Salesdepartment__c ='1.华北营业本部';
|
// equipmentSetInError.Last_Reserve_Rental_Apply_Equipment_Set__c = DemoSetLine.id;
|
// equipmentSetInError.Pre_Reserve_Rental_Apply_Equipment_Set__c =DemoSetLine2.id;
|
// equipmentSetInError.Shipment_request_time__c = Date.today();
|
// equipmentSetInError.Shippment_loaner_time__c = Date.today();
|
// insert equipmentSetInError;
|
|
// Equipment_Set_Detail__c equipmentSetDetailIn_11 = new Equipment_Set_Detail__c();
|
// equipmentSetDetailIn_11.Name = '备品set明细012';
|
// equipmentSetDetailIn_11.Equipment_Set__c = equipmentSetInError.Id;
|
// equipmentSetDetailIn_11.Asset__c = asset2.Id;
|
// equipmentSetDetailIn_11.CurrencyIsoCode = 'CNY';
|
// equipmentSetDetailIn_11.Active_judgement_text__c = okStatus;
|
// equipmentSetDetailIn_11.Select_rental__c = true;
|
|
// Equipment_Set_Detail__c equipmentSetDetailIn_21 = new Equipment_Set_Detail__c();
|
// equipmentSetDetailIn_21.Name = '备品set明细022';
|
// equipmentSetDetailIn_21.Equipment_Set__c = equipmentSetInError.Id;
|
// equipmentSetDetailIn_21.Asset__c = asset2.Id;
|
// equipmentSetDetailIn_21.CurrencyIsoCode = 'CNY';
|
// equipmentSetDetailIn_21.Active_judgement_text__c = okStatus;
|
// equipmentSetDetailIn_21.Select_rental__c = true;
|
|
// insert new Equipment_Set_Detail__c[] {equipmentSetDetailIn_11, equipmentSetDetailIn_21};
|
|
// Equipment_Set__c equipmentSetInError2 = new Equipment_Set__c();
|
// equipmentSetInError2.Name = 'Set03';
|
// equipmentSetInError2.CurrencyIsoCode = 'CNY';
|
// equipmentSetInError2.Loaner_code__c = '备品Set03';
|
// equipmentSetInError2.Shipment_request_time__c = System.now();
|
// equipmentSetInError2.Arrival_in_wh__c = true;
|
// equipmentSetInError2.Loaner_name__c = '备品set03Name';
|
// equipmentSetInError2.Product_category__c = 'SP';
|
// equipmentSetInError2.Loaner_category__c ='主机';
|
// equipmentSetInError2.Equipment_Type__c = '促销用';
|
// equipmentSetInError2.Salesdepartment__c ='1.华北营业本部';
|
// equipmentSetInError2.Arrival_wh_time2__c = System.now();
|
// //equipmentSetInError2.Last_Reserve_Rental_Apply_Equipment_Set__c = DemoSetLine.id;
|
// //equipmentSetInError2.Pre_Reserve_Rental_Apply_Equipment_Set__c =DemoSetLine2.id;
|
// equipmentSetInError2.Shipment_request_time__c = Date.today();
|
// equipmentSetInError2.Shippment_loaner_time__c = Date.today();
|
// insert equipmentSetInError2;
|
|
// //备品set明细
|
// Equipment_Set_Detail__c equipmentSetDetail12 = new Equipment_Set_Detail__c();
|
// equipmentSetDetail12.Name = '备品set明细013';
|
// equipmentSetDetail12.Equipment_Set__c = equipmentSetInError2.Id;
|
// equipmentSetDetail12.Asset__c = asset3.Id;
|
// equipmentSetDetail12.CurrencyIsoCode = 'CNY';
|
// equipmentSetDetail12.Active_judgement_text__c = okStatus;
|
// equipmentSetDetail12.Select_rental__c = true;
|
|
// Equipment_Set_Detail__c equipmentSetDetail22 = new Equipment_Set_Detail__c();
|
// equipmentSetDetail22.Name = '备品set明细023';
|
// equipmentSetDetail22.Equipment_Set__c = equipmentSetInError2.Id;
|
// equipmentSetDetail22.Asset__c = asset3.Id;
|
// equipmentSetDetail22.CurrencyIsoCode = 'CNY';
|
// equipmentSetDetail22.Active_judgement_text__c = okStatus;
|
// equipmentSetDetail22.Select_rental__c = true;
|
|
// insert new Equipment_Set_Detail__c[] {equipmentSetDetail12, equipmentSetDetail22};
|
|
Id execBTId = Database.executeBatch(new EquipmentSetDailyBatch(raObj.id), 20);
|
execBTId = Database.executeBatch(new EquipmentSetDailyBatch(null), 20);
|
}
|
}
|
|
@isTest static void test_method_Three() {
|
// システム管理者
|
User user_admin = new User(Test_staff__c = true);
|
user_admin.LastName = '_サンブリッジ';
|
user_admin.FirstName = 'う';
|
user_admin.Alias = 'う';
|
user_admin.Email = 'olympusTest03@sunbridge.com';
|
user_admin.Username = 'olympusTest03@sunbridge.com';
|
user_admin.CommunityNickname = 'う';
|
user_admin.IsActive = true;
|
user_admin.EmailEncodingKey = 'ISO-2022-JP';
|
user_admin.TimeZoneSidKey = 'Asia/Tokyo';
|
user_admin.LocaleSidKey = 'ja_JP';
|
user_admin.LanguageLocaleKey = 'ja';
|
user_admin.ProfileId = System.Label.ProfileId_SystemAdmin;
|
user_admin.Province__c = '北京';
|
user_admin.Dept__c = '医疗华北营业本部';
|
user_admin.Use_Start_Date__c = Date.today().addMonths(-6);
|
insert user_admin;
|
|
System.runAs(user_admin) {
|
//Profile prof = [select Id from Profile where Name ='系统管理员'];
|
// 病院を作る
|
Account hospital = new Account();
|
hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
|
hospital.Name = 'test hospital';
|
insert hospital;
|
// 产品
|
Product2 pro1 = new Product2(Name='name01',IsActive=true,Family='GI',Asset_Model_No__c='n01',Serial_Lot_No__c='S/N tracing',ProductCode_Ext__c='pc01',Manual_Entry__c=false);
|
Product2 pro2 = new Product2(Name='name02',IsActive=true,Family='GI',Asset_Model_No__c='n02',Serial_Lot_No__c='Lot tracing',ProductCode_Ext__c='pc02',Manual_Entry__c=false);
|
Product2 pro3 = new Product2(Name='name03',IsActive=true,Family='GI',Asset_Model_No__c='n03',Serial_Lot_No__c='S/N tracing',ProductCode_Ext__c='pc03',Manual_Entry__c=false);
|
insert new Product2[] {pro1, pro2, pro3};
|
RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
|
//创建用户
|
user MyUser_Test = [select id,name from user where name =:'SB 葛'];
|
// 戦略科室を得る
|
Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
|
// 診療科を作る
|
Account dep = new Account();
|
dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
|
dep.Name = 'test dep';
|
dep.AgentCode_Ext__c = '9999998';
|
dep.ParentId = strategicDep[0].Id;
|
dep.Department_Class__c = strategicDep[0].Id;
|
dep.Hospital__c = hospital.Id;
|
insert dep;
|
|
Contact contact2 = new Contact();
|
contact2.AccountId = dep.Id;
|
contact2.FirstName = '責任者';
|
contact2.LastName = 'test1经销商';
|
insert contact2;
|
|
// 资产
|
Asset asset1 = new Asset(Asset_Owner__c = 'Olympus');
|
asset1.RecordTypeId = System.Label.Asset_RecordType;
|
asset1.SerialNumber = 'ass01';
|
asset1.Name = 'ass01';
|
asset1.AccountId = dep.Id;
|
asset1.Department_Class__c = strategicDep[0].Id;
|
asset1.Hospital__c = hospital.Id;
|
asset1.Product2Id = pro1.Id;
|
asset1.Quantity = 1;
|
asset1.Manage_type__c = '个体管理';
|
|
Asset asset2 = new Asset(Asset_Owner__c = 'Olympus');
|
asset2.RecordTypeId = System.Label.Asset_RecordType;
|
asset2.SerialNumber = 'ass02';
|
asset2.Loaner_accsessary__c = true;
|
asset2.Name = 'ass02';
|
asset2.AccountId = dep.Id;
|
asset2.Department_Class__c = strategicDep[0].Id;
|
asset2.Hospital__c = hospital.Id;
|
asset2.Quantity = 1;
|
asset2.Product2Id = pro2.Id;
|
|
Asset asset3 = new Asset(Asset_Owner__c = 'Olympus');
|
asset3.RecordTypeId = System.Label.Asset_RecordType;
|
asset3.SerialNumber = 'ass03';
|
asset3.Loaner_accsessary__c = true;
|
asset3.Name = 'ass03';
|
asset3.AccountId = dep.Id;
|
asset3.Department_Class__c = strategicDep[0].Id;
|
asset3.Hospital__c = hospital.Id;
|
asset3.Quantity = 1;
|
asset3.Product2Id = pro3.Id;
|
insert new Asset[] {asset1, asset2,asset3};
|
Opportunity opp1 = new Opportunity(
|
Name='testOpp1',
|
StageName='引合',
|
CloseDate=Date.today(),
|
AccountId=dep.Id,
|
Competitor__c ='A',
|
Click_Close_Date__c = null,
|
RecordType = rectOpp
|
);
|
OPDPlan__c oPDPlan = new OPDPlan__c();
|
oPDPlan.Status__c = '计划中';
|
oPDPlan.OPDPlan_ImplementDate__c = Date.today().addDays(+12);
|
oPDPlan.NoOpp_Reason__c = 'HCP对应';
|
oPDPlan.OPDType__c='科室';
|
insert oPDPlan;
|
|
//新建备品借出申请-普通
|
Rental_Apply__c raObj = new Rental_Apply__c();
|
raObj.Name='*';
|
raObj.Product_category__c = 'GI';
|
raObj.Person_In_Charge__c = MyUser_Test.id;
|
raObj.applyUser__c = MyUser_Test.id;
|
raObj.Hospital__c = hospital.Id;//医院
|
raObj.Strategic_dept__c = strategicDep[0].id;//战略科室
|
raObj.Demo_purpose1__c = '产品试用';
|
raObj.demo_purpose2__c = FixtureUtil.raDemo_purpose2MAP.get('shiyongwuxunjia');
|
raObj.Demo_purpose_text__c ='测试用的备品借出申请';
|
raObj.Request_shipping_day__c = Date.today() + 5;
|
raObj.Hope_Lonaer_date_Num__c = 16;
|
raObj.Loaner_received_staff__c = '测试用户';
|
raObj.Loaner_received_staff_phone__c = '13700008';
|
raObj.direct_send__c = '上门自提';
|
raObj.Account__c = dep.id;//科室
|
raObj.Follow_UP_Opp__c = opp1.Id;
|
raObj.pickup_time__c = Datetime.now()+8;
|
raObj.direct_shippment_address__c = '233333的地址';
|
raObj.Phone_number__c = '1234567890';
|
raObj.Loaner_medical_Staff__c = contact2.Id;
|
raObj.OPDPlan__c = oPDPlan.Id;
|
insert raObj;
|
Rental_Apply_Equipment_Set__c DemoSetLine = new Rental_Apply_Equipment_Set__c();
|
DemoSetLine.Rental_Apply__c = raObj.id;
|
DemoSetLine.IndexFromUniqueKey__c = 1;
|
DemoSetLine.UniqueKey__c = '1:1';
|
Rental_Apply_Equipment_Set__c DemoSetLine2 = new Rental_Apply_Equipment_Set__c();
|
DemoSetLine2.Rental_Apply__c = raObj.id;
|
DemoSetLine2.IndexFromUniqueKey__c = 2;
|
DemoSetLine2.UniqueKey__c = '1:2';
|
|
insert new Rental_Apply_Equipment_Set__c[]{DemoSetLine, DemoSetLine2};
|
|
raObj.Request_approval_time__c = Date.today() - 62;
|
raObj.Status__c = '已批准';
|
update raObj;
|
|
Id execBTId = Database.executeBatch(new EquipmentSetDailyBatch(raObj.id), 20);
|
execBTId = Database.executeBatch(new EquipmentSetDailyBatch(null), 20);
|
}
|
}
|
|
static testMethod void testSchedule() {
|
// This test runs a scheduled job at midnight Sept. 3rd. 2022
|
String CRON_EXP = '0 0 0 3 9 ? 2022';
|
|
System.Test.startTest();
|
// Schedule the test job
|
String jobId = system.schedule('EquipmentSetDailyBatchScheduleTest', CRON_EXP, new EquipmentSetDailyBatchSchedule());
|
// Get the information from the CronTrigger API object
|
CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
|
// Verify the expressions are the same
|
System.assertEquals(CRON_EXP, ct.CronExpression);
|
// Verify the job has not run
|
System.assertEquals(0, ct.TimesTriggered);
|
// Verify the next time the job will run
|
System.assertEquals('2022-09-03 00:00:00', String.valueOf(ct.NextFireTime));
|
System.Test.StopTest();
|
}
|
//2020/11/20 songxiaoqi start
|
@isTest static void test_my_method(){
|
// システム管理者
|
User user_admin = new User(Test_staff__c = true);
|
user_admin.LastName = '_サンブリッジ';
|
user_admin.FirstName = 'う';
|
user_admin.Alias = 'う';
|
user_admin.Email = 'olympusTest03@sunbridge.com';
|
user_admin.Username = 'olympusTest03@sunbridge.com';
|
user_admin.CommunityNickname = 'う';
|
user_admin.IsActive = true;
|
user_admin.EmailEncodingKey = 'ISO-2022-JP';
|
user_admin.TimeZoneSidKey = 'Asia/Tokyo';
|
user_admin.LocaleSidKey = 'ja_JP';
|
user_admin.LanguageLocaleKey = 'ja';
|
user_admin.ProfileId = System.Label.ProfileId_SystemAdmin;
|
user_admin.Province__c = '北京';
|
user_admin.Dept__c = '医疗华北营业本部';
|
user_admin.Use_Start_Date__c = Date.today().addMonths(-6);
|
insert user_admin;
|
|
System.runAs(user_admin) {
|
|
StaticParameter.EscapeNFM001AgencyContractTrigger = true;
|
ControllerUtil.EscapeNFM001Trigger = true;
|
Oly_TriggerHandler.bypass('AssetHandler');
|
Oly_TriggerHandler.bypass('PowerBIBaseHandler');
|
Oly_TriggerHandler.bypass('AgencyOppUpdHandler');
|
Oly_TriggerHandler.bypass('UpdateContractAimAmountHandler');
|
//Profile prof = [select Id from Profile where Name ='系统管理员'];
|
// 病院を作る
|
Account hospital = new Account();
|
hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
|
hospital.Name = 'test hospital';
|
insert hospital;
|
// 产品
|
Product2 pro1 = new Product2(Name='name01',IsActive=true,Family='GI',Asset_Model_No__c='n01',Serial_Lot_No__c='S/N tracing',ProductCode_Ext__c='pc01',Manual_Entry__c=false);
|
Product2 pro2 = new Product2(Name='name02',IsActive=true,Family='GI',Asset_Model_No__c='n02',Serial_Lot_No__c='Lot tracing',ProductCode_Ext__c='pc02',Manual_Entry__c=false);
|
Product2 pro3 = new Product2(Name='name03',IsActive=true,Family='GI',Asset_Model_No__c='n03',Serial_Lot_No__c='S/N tracing',ProductCode_Ext__c='pc03',Manual_Entry__c=false);
|
insert new Product2[] {pro1, pro2, pro3};
|
RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
|
//创建用户
|
user MyUser_Test = [select id,name from user where name =:'SB 葛'];
|
// 戦略科室を得る
|
Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
|
// 診療科を作る
|
Account dep = new Account();
|
dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
|
dep.Name = 'test dep';
|
dep.AgentCode_Ext__c = '9999998';
|
dep.ParentId = strategicDep[0].Id;
|
dep.Department_Class__c = strategicDep[0].Id;
|
dep.Hospital__c = hospital.Id;
|
insert dep;
|
|
Contact contact2 = new Contact();
|
contact2.AccountId = dep.Id;
|
contact2.FirstName = '責任者';
|
contact2.LastName = 'test1经销商';
|
insert contact2;
|
|
// 资产
|
Asset asset1 = new Asset(Asset_Owner__c = 'Olympus');
|
asset1.RecordTypeId = System.Label.Asset_RecordType;
|
asset1.SerialNumber = 'ass01';
|
asset1.Name = 'ass01';
|
asset1.AccountId = dep.Id;
|
asset1.Department_Class__c = strategicDep[0].Id;
|
asset1.Hospital__c = hospital.Id;
|
asset1.Product2Id = pro1.Id;
|
asset1.Quantity = 1;
|
asset1.Manage_type__c = '个体管理';
|
|
Asset asset2 = new Asset(Asset_Owner__c = 'Olympus');
|
asset2.RecordTypeId = System.Label.Asset_RecordType;
|
asset2.SerialNumber = 'ass02';
|
asset2.Loaner_accsessary__c = true;
|
asset2.Name = 'ass02';
|
asset2.AccountId = dep.Id;
|
asset2.Department_Class__c = strategicDep[0].Id;
|
asset2.Hospital__c = hospital.Id;
|
asset2.Quantity = 1;
|
asset2.Product2Id = pro2.Id;
|
|
Asset asset3 = new Asset(Asset_Owner__c = 'Olympus');
|
asset3.RecordTypeId = System.Label.Asset_RecordType;
|
asset3.SerialNumber = 'ass03';
|
asset3.Loaner_accsessary__c = true;
|
asset3.Name = 'ass03';
|
asset3.AccountId = dep.Id;
|
asset3.Department_Class__c = strategicDep[0].Id;
|
asset3.Hospital__c = hospital.Id;
|
asset3.Quantity = 1;
|
asset3.Product2Id = pro3.Id;
|
insert new Asset[] {asset1, asset2,asset3};
|
|
Opportunity opp1 = new Opportunity(
|
Name='testOpp1',
|
StageName='引合',
|
CloseDate=Date.today(),
|
AccountId=dep.Id,
|
Competitor__c ='A',
|
Click_Close_Date__c = null,
|
RecordType = rectOpp
|
);
|
Opportunity opp2 = new Opportunity(
|
Name='testOpp1',
|
StageName='引合',
|
CloseDate=Date.today(),
|
AccountId=dep.Id,
|
Sales_Root__c = 'OCM直接販売',
|
Competitor__c ='A',
|
Click_Close_Date__c = null,
|
RecordType = rectOpp
|
);
|
insert new Opportunity[] {opp2, opp1};
|
//注残
|
Statu_Achievements__c Sac = new Statu_Achievements__c(
|
name = 'zhucan_one',
|
Opportunity__c = opp2.id,
|
DeliveryDate__c = Date.today(),
|
ContractAmount__c = 0
|
);
|
insert Sac;
|
Test.startTest();
|
// 修理を作成する01
|
Repair__c repair01 = new Repair__c();
|
repair01.Account__c = dep.Id;
|
repair01.Department_Class__c = strategicDep[0].Id;
|
repair01.Hospital__c = hospital.Id;
|
repair01.Delivered_Product__c = asset1.Id;
|
repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays( -11); // 维修合同判断日がサービス契約開始日の前日
|
repair01.Repair_Start_Date__c = Date.today().addDays(-9);
|
repair01.Repair_Final_Inspection_Date__c = null;
|
repair01.Repair_Ordered_Date__c = Date.today();
|
repair01.SAP_Transfer_time__c = Date.today();
|
insert repair01;
|
|
//新建备品借出申请-普通
|
OPDPlan__c oPDPlan = new OPDPlan__c();
|
oPDPlan.Status__c = '计划中';
|
oPDPlan.OPDPlan_ImplementDate__c = Date.today().addDays(+12);
|
oPDPlan.NoOpp_Reason__c = 'HCP对应';
|
oPDPlan.OPDType__c='科室';
|
insert oPDPlan;
|
//新建备品借出申请-已购待货
|
Rental_Apply__c raObj = new Rental_Apply__c();
|
raObj.Name='*';
|
raObj.Product_category__c = 'GI';
|
raObj.Person_In_Charge__c = user_admin.id;
|
raObj.applyUser__c = user_admin.id;
|
raObj.Hospital__c = hospital.Id;//医院
|
raObj.Strategic_dept__c = strategicDep[0].id;//战略科室
|
raObj.Demo_purpose1__c = '产品试用';
|
//raObj.demo_purpose2__c ='已购待货';
|
raObj.demo_purpose2__c = '索赔QIS';
|
// raObj.Request_demo_day__c =null;
|
// raObj.Request_demo_day__c = '2020-05-20';
|
raObj.Demo_purpose_text__c ='测试用的备品借出申请';
|
raObj.Request_shipping_day__c = Date.today() + 5;
|
// raObj.Hope_Lonaer_date_Num__c = 16; // 希望借用天数
|
raObj.Loaner_received_staff__c = '测试用户';
|
raObj.Loaner_received_staff_phone__c = '13700008';
|
raObj.direct_send__c = '上门自提';
|
raObj.Repair__c = repair01.id;
|
raObj.Statu_Achievements__c = Sac.id;
|
raObj.Account__c = dep.id;//科室
|
raObj.Follow_UP_Opp__c = opp2.Id;
|
raObj.pickup_time__c = Datetime.now()+8;
|
raObj.direct_shippment_address__c = '233333的地址';
|
raObj.Phone_number__c = '1234567890';
|
raObj.Loaner_medical_Staff__c = contact2.Id;
|
raObj.OPDPlan__c = oPDPlan.Id;
|
raObj.Status__c ='草案中';
|
//新建备品借出申请-已购待货
|
Rental_Apply__c raObj1 = new Rental_Apply__c();
|
raObj1.Name='*';
|
raObj1.Product_category__c = 'GI';
|
raObj1.Person_In_Charge__c = user_admin.id;
|
raObj1.applyUser__c = user_admin.id;
|
raObj1.Hospital__c = hospital.Id;//医院
|
raObj1.Strategic_dept__c = strategicDep[0].id;//战略科室
|
raObj1.Demo_purpose1__c = '维修代用';
|
//raObj1.demo_purpose2__c ='保修用户';
|
raObj1.demo_purpose2__c ='保修用户';
|
raObj1.Demo_purpose_text__c ='测试用的备品借出申请';
|
raObj1.Request_shipping_day__c = Date.today() + 5;
|
// raObj1.Hope_Lonaer_date_Num__c = 16;
|
raObj1.Loaner_received_staff__c = '测试用户';
|
raObj1.Loaner_received_staff_phone__c = '13700008';
|
raObj1.direct_send__c = '上门自提';
|
raObj1.Repair__c = repair01.id;
|
raObj1.Account__c = dep.id;//科室
|
raObj1.Follow_UP_Opp__c = opp1.Id;
|
raObj1.pickup_time__c = Datetime.now()+8;
|
raObj1.direct_shippment_address__c = '233333的地址';
|
raObj1.Phone_number__c = '1234567890';
|
raObj1.Loaner_medical_Staff__c = contact2.Id;
|
raObj1.OPDPlan__c = oPDPlan.Id;
|
raObj1.Status__c ='草案中';
|
try {
|
insert new Rental_Apply__c[]{raObj,raObj1} ;
|
} catch (Exception e) {
|
System.debug('Exception---' + e);
|
}
|
/**
|
//repair01.Repair_Shipped_Date__c = Date.today().addDays(-14);
|
//update repair01;
|
Rental_Apply_Equipment_Set__c DemoSetLine3 = new Rental_Apply_Equipment_Set__c();
|
DemoSetLine3.Rental_Apply__c = raObj.id;
|
DemoSetLine3.Extend_Date__c = Date.today();
|
DemoSetLine3.Received_Confirm__c = 'OK';
|
//DemoSetLine3.Final_reply_day__c = Date.today();
|
//DemoSetLine3.Shippment_loaner_time2__c = Date.today();
|
DemoSetLine3.IndexFromUniqueKey__c = 1;
|
DemoSetLine3.UniqueKey__c = '1:1';
|
DemoSetLine3.DataMigration_Flag__c =true;
|
List<Rental_Apply_Equipment_Set__c> acs = [select Id,Final_reply_day__c from Rental_Apply_Equipment_Set__c ];
|
//System.AssertException(2,acs.size());
|
//System.assertEquals(2,acs.size());
|
Rental_Apply_Equipment_Set__c DemoSetLine4 = new Rental_Apply_Equipment_Set__c();
|
DemoSetLine4.Rental_Apply__c = raObj1.id;
|
DemoSetLine4.Extend_Date__c = Date.today();
|
DemoSetLine4.Received_Confirm__c = 'OK';
|
DemoSetLine4.IndexFromUniqueKey__c = 2;
|
DemoSetLine4.UniqueKey__c = '1:2';
|
|
//DemoSetLine4.Final_reply_day__c = Date.today();
|
DemoSetLine4.Rental_End_Date__c = Date.today();
|
DemoSetLine4.DataMigration_Flag__c =true;
|
DemoSetLine3.Shippment_loaner_time__c = System.now().addDays(-10);
|
insert new Rental_Apply_Equipment_Set__c[]{DemoSetLine3,DemoSetLine4};
|
**/
|
//System.assertEquals(RaesList[0].Final_reply_day__c ,Date.today());
|
id execBTId = Database.executeBatch(new EquipmentSetDailyBatch(null), 20);
|
Test.stopTest();
|
}
|
}
|
//2020/11/20 songxiaoqi end
|
|
}
|