@isTest
public with sharing class lexTmsformControllerTest {
    @TestSetup
    private static void init() {

        Address_Level__c al = new Address_Level__c();
        al.Name = '東京';
        al.Level1_Code__c = 'CN-99';
        al.Level1_Sys_No__c = '999999';
        insert al;

        Address_Level2__c al2 = new Address_Level2__c();
        al2.Level1_Code__c = 'CN-99';
        al2.Level1_Sys_No__c = '999999';
        al2.Level1_Name__c = '東京';
        al2.Name = '渋谷区';
        al2.Level2_Code__c = 'CN-9999';
        al2.Level2_Sys_No__c = '9999999';
        al2.Address_Level__c = al.id;
        insert al2;
        Account accDep = new Account();
        accDep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Agency'].id;
        accDep.Name = '山东省虚拟经销商';
        accDep.Is_Active__c = '有效';
        accDep.TradeComplianceStatus__c = '警示名单';
        accDep.State_Master__c = al.Id;
        accDep.Aim_Price__c = 41421421;
        accDep.ParentId = '001C8000002Se0tIAC';
        accDep.ET_SP_Dealer__c = true;
        accDep.ISVirtualDealer__c = true;

        insert accDep;

        Dealer_ConsumableManage__c dc = new Dealer_ConsumableManage__c();
        dc.Dealer_Name__c = accDep.id;
        dc.TMS_Key__c = accDep.id+'-'+'ET'+'-'+'FY2024'+'-'+accDep.OCM_man_province_HP__c;
        dc.ET_ENG__c = 'ET';
        dc.FY__c = 'FY2024';
        dc.FY_O_1__c = 123;
        dc.FY_O_10__c = 123;
        dc.FY_O_11__c = 123;
        dc.FY_O_12__c = 123;
        dc.FY_O_2__c = 123;
        dc.FY_O_3__c = 123;
        dc.FY_O_4__c = 123;
        dc.FY_O_5__c = 123;
        dc.FY_O_6__c = 123;
        dc.FY_O_7__c = 123;
        dc.FY_O_8__c = 123;
        dc.FY_O_9__c = 123;
        
        dc.FY_P_1__c = 123;
        dc.FY_P_10__c = 123;
        dc.FY_P_11__c = 123;
        dc.FY_P_12__c = 123;
        dc.FY_P_2__c = 123;
        dc.FY_P_3__c = 123;
        dc.FY_P_4__c = 123;
        dc.FY_P_5__c = 123;
        dc.FY_P_6__c = 123;
        dc.FY_P_7__c = 123;
        dc.FY_P_8__c = 123;
        dc.FY_P_9__c = 123;

        dc.FY_S_1__c = 123;
        dc.FY_S_10__c = 123;
        dc.FY_S_11__c = 123;
        dc.FY_S_12__c = 123;
        dc.FY_S_2__c = 123;
        dc.FY_S_3__c = 123;
        dc.FY_S_4__c = 123;
        dc.FY_S_5__c = 123;
        dc.FY_S_6__c = 123;
        dc.FY_S_7__c = 123;
        dc.FY_S_8__c = 123;
        dc.FY_S_9__c = 123;

        dc.FY_I_1__c = 123;
        dc.FY_I_10__c = 123;
        dc.FY_I_11__c = 123;
        dc.FY_I_12__c = 123;
        dc.FY_I_2__c = 123;
        dc.FY_I_3__c = 123;
        dc.FY_I_4__c = 123;
        dc.FY_I_5__c = 123;
        dc.FY_I_6__c = 123;
        dc.FY_I_7__c = 123;
        dc.FY_I_8__c = 123;
        dc.FY_I_9__c = 123;

        dc.TMS_Unpaid_amount_1__c = 123;
        dc.TMS_Unpaid_amount_10__c = 123;
        dc.TMS_Unpaid_amount_11__c = 123;
        dc.TMS_Unpaid_amount_12__c = 123;
        dc.TMS_Unpaid_amount_2__c = 123;
        dc.TMS_Unpaid_amount_3__c = 123;
        dc.TMS_Unpaid_amount_4__c = 123;
        dc.TMS_Unpaid_amount_5__c = 123;
        dc.TMS_Unpaid_amount_6__c = 123;
        dc.TMS_Unpaid_amount_7__c = 123;
        dc.TMS_Unpaid_amount_8__c = 123;
        dc.TMS_Unpaid_amount_9__c = 123;

        dc.TMS_Prediction_1__c = 123;
        dc.TMS_Prediction_10__c = 123;
        dc.TMS_Prediction_11__c = 123;
        dc.TMS_Prediction_12__c = 123;
        dc.TMS_Prediction_2__c = 123;
        dc.TMS_Prediction_3__c = 123;
        dc.TMS_Prediction_4__c = 123;
        dc.TMS_Prediction_5__c = 123;
        dc.TMS_Prediction_6__c = 123;
        dc.TMS_Prediction_7__c = 123;
        dc.TMS_Prediction_8__c = 123;
        dc.TMS_Prediction_9__c = 123;

        dc.IMS_Shipments_1__c = 123;
        dc.IMS_Shipments_10__c = 123;
        dc.IMS_Shipments_11__c = 123;
        dc.IMS_Shipments_12__c = 123;
        dc.IMS_Shipments_2__c = 123;
        dc.IMS_Shipments_3__c = 123;
        dc.IMS_Shipments_4__c = 123;
        dc.IMS_Shipments_5__c = 123;
        dc.IMS_Shipments_6__c = 123;
        dc.IMS_Shipments_7__c = 123;
        dc.IMS_Shipments_8__c = 123;
        dc.IMS_Shipments_9__c = 123;

        dc.IMS_Prediction_1__c = 123;
        dc.IMS_Prediction_10__c = 123;
        dc.IMS_Prediction_11__c = 123;
        dc.IMS_Prediction_12__c = 123;
        dc.IMS_Prediction_2__c = 123;
        dc.IMS_Prediction_3__c = 123;
        dc.IMS_Prediction_4__c = 123;
        dc.IMS_Prediction_5__c = 123;
        dc.IMS_Prediction_6__c = 123;
        dc.IMS_Prediction_7__c = 123;
        dc.IMS_Prediction_8__c = 123;
        dc.IMS_Prediction_9__c = 123;

        dc.TMS_PredictionFulfillment_1__c = 123;
        dc.TMS_PredictionFulfillment_10__c = 123;
        dc.TMS_PredictionFulfillment_11__c = 123;
        dc.TMS_PredictionFulfillment_12__c = 123;
        dc.TMS_PredictionFulfillment_2__c = 123;
        dc.TMS_PredictionFulfillment_3__c = 123;
        dc.TMS_PredictionFulfillment_4__c = 123;
        dc.TMS_PredictionFulfillment_5__c = 123;
        dc.TMS_PredictionFulfillment_6__c = 123;
        dc.TMS_PredictionFulfillment_7__c = 123;
        dc.TMS_PredictionFulfillment_8__c = 123;
        dc.TMS_PredictionFulfillment_9__c = 123;

        insert dc;
        

        
        // 戦略科室を得る
        Address_Level__c address = new Address_Level__c(Level1_Code__c = 'CN-01',Name='北京市');
            insert address;
            // 病院を作る
            Account hospital = new Account();
            hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Agency'].id;
            hospital.Name = 'test hospital';
            hospital.Is_Active__c = '有效';
            hospital.TradeComplianceStatus__c = '警示名单';
            hospital.State_Master__c = address.Id;
            hospital.Aim_Price__c = 41421421;
            hospital.Agent_Ref__c = '001C8000002Se9aIAC';
            hospital.ParentId = '001C8000002Se9aIAC';
            hospital.ET_SP_Dealer__c = true;
            insert hospital;
        Oly_TriggerHandler.bypass('ConsumableAssetHander');
        Oly_TriggerHandler.bypass('Oly_TriggerHandler');
        Oly_TriggerHandler.bypass('ConsumableAssetUp');
        Consumable_order_details2__c saledet1 = new Consumable_order_details2__c();
        saledet1.Name = 'OCM_01_001001';

        saledet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
        saledet1.Bar_Code__c = '0114953170032070111804001082K250BBBBB';

        saledet1.Used_account__c = hospital.Id;
        saledet1.Delivery_List_RMB__c = 11;
        saledet1.Box_Piece__c = '盒';
        saledet1.TracingCode__c = 'BBBBB';
        saledet1.SerialLotNo__c = '82K';
        saledet1.Intra_Trade_List_RMB__c = 32142;
        saledet1.Guarantee_period_for_products__c = Date.today().addDays(5);
        saledet1.Sterilization_limit__c = Date.today().addDays(5);
        saledet1.Send_Date__c = null;
        saledet1.Arrive_date__c = Date.today().addDays(5);
        saledet1.Used_date__c = null;
        saledet1.Used_Account_Type__c = '契約';
        saledet1.Deliver_date__c = Date.today().addDays(-50);
        saledet1.Consumable_product__c = 'a36C80000000IeOIAU';
        insert saledet1;

        Consumable_order_details2__c saledet3 = new Consumable_order_details2__c();
        saledet3.Name = 'OCM_01_0010012';

        saledet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
        saledet3.Bar_Code__c = '0114953170032070111804001082K250BBBBA';

        saledet3.Used_account__c = hospital.Id;
        saledet3.Delivery_List_RMB__c = 11;
        saledet3.Box_Piece__c = '盒';
        saledet3.TracingCode__c = 'BBBBB';
        saledet3.SerialLotNo__c = '82K';
        saledet3.Intra_Trade_List_RMB__c = 321342;
        saledet3.Guarantee_period_for_products__c = Date.today().addDays(5);
        saledet3.Sterilization_limit__c = Date.today().addDays(5);
        saledet3.Send_Date__c = null;
        saledet3.Arrive_date__c = Date.today().addDays(5);
        saledet3.Used_date__c = null;
        saledet3.Used_Account_Type__c = '販売店';
        saledet3.Deliver_date__c = Date.today().addMonths(3);
        insert saledet3;
        Consumable_order_details2__c saledet4 = new Consumable_order_details2__c();
        saledet4.Name = 'OCM_01_0010012';

        saledet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
        saledet4.Bar_Code__c = '0114953170032070111804001082K250BBBBA';

        saledet4.Used_account__c = hospital.Id;
        saledet4.Delivery_List_RMB__c = 11;
        saledet4.Box_Piece__c = '盒';
        saledet4.TracingCode__c = 'BBBBB';
        saledet4.SerialLotNo__c = '82K';
        saledet4.Intra_Trade_List_RMB__c = 321342;
        saledet4.Guarantee_period_for_products__c = Date.today().addDays(5);
        saledet4.Sterilization_limit__c = Date.today().addDays(5);
        saledet4.Send_Date__c = null;
        saledet4.Arrive_date__c = Date.today().addDays(5);
        saledet4.Used_date__c = null;
        saledet4.Used_Account_Type__c = '販売店';
        saledet4.Deliver_date__c = Date.today().addMonths(-4);
        saledet4.Consumable_product__c = 'a36C80000000IeOIAU';
        insert saledet4;
        Consumable_order_details2__c saledet5 = new Consumable_order_details2__c();
        saledet5.Name = 'OCM_01_0010012';

        saledet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
        saledet5.Bar_Code__c = '0114953170032070111804001082K250BBBBA';

        saledet5.Used_account__c = hospital.Id;
        saledet5.Delivery_List_RMB__c = 11;
        saledet5.Box_Piece__c = '盒';
        saledet5.TracingCode__c = 'BBBBB';
        saledet5.SerialLotNo__c = '82K';
        saledet5.Intra_Trade_List_RMB__c = 321342;
        saledet5.Guarantee_period_for_products__c = Date.today().addDays(5);
        saledet5.Sterilization_limit__c = Date.today().addDays(-5);
        saledet5.Send_Date__c = null;
        saledet5.Arrive_date__c = Date.today().addDays(5);
        saledet5.Used_date__c = null;
        saledet5.Used_Account_Type__c = '販売店';
        saledet5.Deliver_date__c = Date.today().addMonths(5);
        insert saledet5;
        Consumable_order_details2__c saledet6 = new Consumable_order_details2__c();
        saledet6.Name = 'OCM_01_0010012';

        saledet6.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
        saledet6.Bar_Code__c = '0114953170032070111804001082K250BBBBA';

        saledet6.Used_account__c = hospital.Id;
        saledet6.Delivery_List_RMB__c = 11;
        saledet6.Box_Piece__c = '盒';
        saledet6.TracingCode__c = 'BBBBB';
        saledet6.SerialLotNo__c = '82K';
        saledet6.Intra_Trade_List_RMB__c = 321342;
        saledet6.Guarantee_period_for_products__c = Date.today().addDays(5);
        saledet6.Sterilization_limit__c = Date.today().addDays(5);
        saledet6.Send_Date__c = null;
        saledet6.Arrive_date__c = Date.today().addDays(5);
        saledet6.Used_date__c = null;
        saledet6.Used_Account_Type__c = '販売店';
        saledet6.Deliver_date__c = Date.today().addMonths(6);
        insert saledet6;
    }
    static testMethod void testInitOTwo(){
        Account acc = [select id,name ,OCM_man_province_HP__c  from Account limit 1];
        lexTmsformController.initData('','大连',null,'ET耗材',null,'FY2024',null);
    }

    static testMethod void testInitOOne(){
        lexTmsformController.initData2('','大连',null,'ET耗材',null,'FY2024',null);
    }
    static testMethod void testInitOTree(){
        
    }
}