高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
@isTest
private class OPDSortManageControllerTest {
  public static User user = new User();
    static testMethod void testMethod1() {            
        //OPD计划
        OPDPlan__c oPDPlan1 = new OPDPlan__c();
        oPDPlan1.Status__c = '计划中';
        oPDPlan1.OPDPlan_ImplementDate__c =  Date.today().addMonths(1);
        oPDPlan1.NoOpp_Reason__c = 'HCP对应';     //无询价理由
        oPDPlan1.OPDLendSortDraft__c = 1;       //备品借出优先度
        //oPDPlan1.OPDType__c = '学会';
        insert oPDPlan1;
 
        OPDPlan__c oPDPlan2 = new OPDPlan__c();
        oPDPlan2.Status__c = '计划中';
        oPDPlan2.OPDPlan_ImplementDate__c = Date.today().addMonths(1);
        oPDPlan2.NoOpp_Reason__c = 'HCP对应'; 
        //oPDPlan2.OPDType__c = '学会';
        insert oPDPlan2;
 
 
        OPDPlan__c oPDPlan3 = new OPDPlan__c();
        oPDPlan3.Status__c = '计划中';
        oPDPlan3.OPDPlan_ImplementDate__c = Date.today().addMonths(1);
        oPDPlan3.NoOpp_Reason__c = 'HCP对应'; 
        oPDPlan3.OPDLendSortDraft__c = 2;
        //oPDPlan3.OPDType__c = '学会';
        insert oPDPlan3;
 
        OPDPlan__c oPDPlan4 = new OPDPlan__c();
        oPDPlan4.Status__c = '计划中';
        oPDPlan4.OPDPlan_ImplementDate__c = Date.today().addMonths(1);
        oPDPlan4.NoOpp_Reason__c = 'HCP对应'; 
        //oPDPlan4.OPDType__c = '学会';
        insert oPDPlan4;
 
 
        OPDPlan__c oPDPlan5 = new OPDPlan__c();     
        oPDPlan5.Status__c = '计划中';
        oPDPlan5.OPDPlan_ImplementDate__c = Date.today().addMonths(1);
        oPDPlan5.NoOpp_Reason__c = 'HCP对应'; 
        //oPDPlan5.OPDType__c = '学会';
        oPDPlan5.IsJump__c = true;
        oPDPlan5.JumpCause__c = '想插队';
        oPDPlan5.OPDLendSortDraft__c = 15;
        insert oPDPlan5;
 
        OPDPlan__c oPDPlan6 = new OPDPlan__c();     
        oPDPlan6.Status__c = '计划中';
        oPDPlan6.OPDPlan_ImplementDate__c = Date.today().addMonths(1);
        oPDPlan6.NoOpp_Reason__c = 'HCP对应'; 
        //oPDPlan6.OPDType__c = '学会';
        oPDPlan6.IsJump__c = true;
        oPDPlan6.JumpCause__c = '想插队';
        oPDPlan6.OPDLendSort__c = 0;
        insert oPDPlan6;
        
        OPDPlan__c oPDPlan7 = new OPDPlan__c();     
        oPDPlan7.Status__c = '计划中';
        oPDPlan7.OPDPlan_ImplementDate__c = Date.today().addMonths(1);
        oPDPlan7.NoOpp_Reason__c = 'HCP对应'; 
        //oPDPlan7.OPDType__c = '学会';
        oPDPlan7.IsJump__c = true;
        oPDPlan7.JumpCause__c = '想插队';
        insert oPDPlan7;
 
        user = getUser();
 
        List<OPDPlan__c> oplist = [select id,IsJump__c,JumpCause__c,OPDLendSortDraft__c,OPDLendSort__c,IsSaveOrSubmit__c from OPDPlan__c where Status__c='计划中'];
        System.assertEquals(7, oplist.size());
 
        PageReference ref = new PageReference('/apex/OPDSortManage');
        Test.setCurrentPage(ref);
        OPDSortManageController target = new OPDSortManageController();
        target.init();
        System.assertEquals(2, target.unCheckedOPDPlan.size()); //未排序的
        //target.Salesdepartment = '1.华北';
        target.searchBtn();
        //System.assertEquals(2, target.unCheckedOPDPlan.size()); //未排序的
        target.unCheckedOPDPlan[0].check = true;
        target.saveAdd();
        target.autoSort();
        target.opdDelId = oPDPlan5.id;
        target.del();
        target.checkedOPDPlan[4].op.OPDLendSortDraft__c = 18;
        target.save();
        //2020-12-02  mzy add 点击项目自行排序功能
        target.sortTableFlagSort ='asc';
        target.sortKey ='Sort';
        target.sortTable();
        target.sortTableFlagNDetail ='asc';
        target.sortKey ='NDetail';
        target.sortTable();
        target.sortTableFlagNtime ='asc';
        target.sortKey ='Ntime';
        target.sortTable();
        //2020-12-02  mzy add 点击项目自行排序功能
        System.runAs(user) {  
            List<Group> glist = [select id from group WHERE DeveloperName in ('X00_LOHBbeijing')];
            GroupMember mb = new GroupMember();
            mb.groupid =  glist[0].id;
            mb.userOrGroupId = user.id;
            insert mb;
            target.submitBtn();
        }
    }
 
    private static User getUser() {
    String timenow = Datetime.now().format('yyyyMMddHHmmss');
    User usr = new User(Test_staff__c = true, LastName = 'TestZY', FirstName = 'TestZY',
                            Alias = 'zy', CommunityNickname = 'TestMiao', Email = 'TestZY@test.com',
                            Username = 'Test' + timenow + '@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP',
                            TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = System.Label.ProfileId_SystemAdmin,
                            Province__c = '北京市',Work_Location__c = '北京');
    insert usr;
    return usr;
  }
 
}