buli
2022-05-14 ead4df22dca33a867279471821ca675f91dec760
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
@isTest
private class BusinessActivityHandlerTest {
    public static TS_Repair__c tsr;
    public static TS_Repair__c tsr2;
    public static BusinessActivity__c ba1;
    public static BusinessActivity__c ba2;
    public static BusinessActivity__c ba3;
    public static BusinessActivity__c ba4;
 
    public static User_FaultInfo__c uf1;
    public static User_FaultInfo__c uf2;
    public static User_FaultInfo__c uf3;
 
    public static FailureAsset__c fa1;
    public static FailureAsset__c fa2;
    public static FailureAsset__c fa3;
    static void basicData() {
 
        tsr = new TS_Repair__c();
        tsr.TSReportDate__c = Date.today();
        tsr.TSRepairManagementCode__c = 'TestName';
        insert tsr;    
        tsr2 = new TS_Repair__c();
        tsr2.TSReportDate__c = Date.today();
        insert tsr2;
 
        uf1 = new User_FaultInfo__c();
        insert uf1;
        fa1 = new FailureAsset__c();
        fa1.model__c = 'test1';
        fa1.FAUserFaultInfo__c = uf1.Id;
        insert fa1;
        ba1 = new BusinessActivity__c();
        ba1.BusinessATS__c = tsr.Id;
        ba1.workingHours__c = 2;
        ba1.BusinessAApprovalOpinion__c = '同意';
        ba1.User_FaultInfo__c = uf1.Id;
        ba1.AgreeReportDate__c = Date.today().addDays(-2);//报告日期(后台用)
        ba1.BusinessADateRequest__c = Date.today().addDays(-3);//要求服务日期
        ba1.BusinessACompletionDate__c = Date.today().addDays(-2);//案件完成日
        ba1.BusinessADateApproval__c= Date.today().addDays(-2);//同意报价日期
        ba1.BusinessADateQuotation__c= Date.today().addDays(-2);// 报价日期
        ba1.BusinessARepairDate__c= Date.today().addDays(-2);//报修日期
        ba1.BusinessASegment__c = 'LS';
        ba1.BusinessAServicePlace__c = '现场';
        ba1.serviceType__c = '硬件修理';
        ba1.BusinessAServiceCategory__c = 'Repair';
        
        ba1.BusinessANatureService__c = '有偿';
        ba1.BusinessAFirstSubmission__c = Datetime.now();
        insert ba1;
 
        ba4 = new BusinessActivity__c();
        ba4.BusinessATS__c = tsr.Id;
        ba4.workingHours__c = 7;
        ba4.BusinessAApprovalOpinion__c = '';
        ba4.User_FaultInfo__c = uf1.Id;
 
        ba4.AgreeReportDate__c = Date.today().addDays(1);//报告日期(后台用)
        ba4.BusinessADateRequest__c = Date.today().addDays(2);//要求服务日期
        ba4.BusinessACompletionDate__c = Date.today().addDays(1);//案件完成日
        ba4.BusinessADateApproval__c= Date.today().addDays(4);//同意报价日期
        ba4.BusinessADateQuotation__c= Date.today().addDays(1);// 报价日期
        ba4.BusinessARepairDate__c= Date.today().addDays(-3);//报修日期
        ba4.BusinessASegment__c = 'LS';
        ba4.BusinessAServicePlace__c = '现场';
        ba4.serviceType__c = '硬件修理';
        ba4.BusinessAServiceCategory__c = 'Repair';
        
        ba4.BusinessANatureService__c = '无偿';
        ba4.BusinessAFirstSubmission__c = Datetime.now();
        insert ba4;
 
 
        BusinessActivity__c ba5 = new BusinessActivity__c();
        ba5.FindManagementCode__c = 'TestName';
        ba5.BusinessATS__c = tsr.Id;
        ba5.workingHours__c = 7;
        ba5.BusinessAApprovalOpinion__c = '';
        ba5.User_FaultInfo__c = uf1.Id;
        ba5.BusinessASegment__c = 'RVI';
        ba5.serviceType__c = '产品安装';
        ba5.BusinessAServiceCategory__c = 'Sevice';
 
        insert ba5;
        update ba5;
        BusinessActivity__c ba6 =  ba5.clone();
        ba6.BusinessASegment__c = 'LS';
        ba6.BusinessAServicePlace__c = '现场';
        ba6.serviceType__c = '硬件修理';
        ba6.BusinessAServiceCategory__c = 'Repair';
        
        ba6.BusinessANatureService__c = '有偿';
        insert ba6;
 
        delete ba6;
        // uf2 = new User_FaultInfo__c();
        // insert uf2;
        // fa2 = new FailureAsset__c();
        // fa2.model__c = 'test2';
        // fa2.FAUserFaultInfo__c = uf2.Id;
        // insert fa2;
        // ba2 = new BusinessActivity__c();
        // ba2.BusinessATS__c = tsr2.Id;
        // ba2.workingHours__c = 2;
        // ba2.User_FaultInfo__c = uf2.Id;
        // insert ba2;
 
        // uf3 = new User_FaultInfo__c();
        // insert uf3;
        // fa3 = new FailureAsset__c();
        // fa3.model__c = 'test3';
        // fa3.FAUserFaultInfo__c = uf3.Id;
        // insert fa3;
        // ba3 = new BusinessActivity__c();
        // ba3.BusinessATS__c = tsr2.Id;
        // ba3.workingHours__c = 2;
        // ba3.User_FaultInfo__c = uf3.Id;
        // insert ba3;
 
        // Attachment att = new Attachment(
        //     Name = 'ORDER-123456.pdf',
        //     parentId = ba1.Id,
        //     Body = EncodingUtil.base64Decode('test')
        // );
        // insert att;
 
        // Attachment att2 = new Attachment(
        //     Name = 'not-ORDER-123456.pdf',
        //     parentId = ba2.Id,
        //     Body = EncodingUtil.base64Decode('test')
        // );
        // insert att2;
 
    }
    static testMethod void testMethod1() {
        basicData();
        update uf1;
    }
}