高章伟
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
public with sharing class RentalSequenceWatchController {
    public List<Rental_Apply_Sequence__c> rasShowCFList{get;set;}
    public List<Rental_Apply_Sequence__c> rasShowTHList{get;set;}
    public List<Rental_Apply_Equipment_Set_Detail__c> raesDShowCFList{get;set;}
    public List<Rental_Apply_Equipment_Set_Detail__c> raesDShowTHList{get;set;}
 
    public Boolean haveErrCF_X{get;set;}
    public Boolean haveErrTH_X{get;set;}
    public Boolean haveErrCF_D{get;set;}
    public Boolean haveErrTH_D{get;set;}
    public RentalSequenceWatchController() {
        haveErrCF_X = false;
        haveErrTH_X = false;
        haveErrCF_D = false;
        haveErrTH_D = false;
        rasShowCFList = new List<Rental_Apply_Sequence__c>();
        rasShowTHList = new List<Rental_Apply_Sequence__c>();
        raesDShowCFList = new List<Rental_Apply_Equipment_Set_Detail__c>();
        raesDShowTHList = new List<Rental_Apply_Equipment_Set_Detail__c>();
    }
    public void init(){
        Map<String,String> esnMap = new Map<String,String>();
        Map<String,String> ekeyMap = new Map<String,String>();
        List<Rental_Apply_Sequence__c> rasList = [Select Id,ExternalKey_Series_No__c, Series_No__c,ExternalKey__c From Rental_Apply_Sequence__c where Invalid_Flag__c = false order by ExternalKey__c,Series_No__c];
        Integer i = 1;
        for(Rental_Apply_Sequence__c ras:rasList){
            if(esnMap.containsKey(ras.ExternalKey_Series_No__c)){
                rasShowCFList.add(ras);
            }else{
                esnMap.put(ras.ExternalKey_Series_No__c,ras.ExternalKey_Series_No__c);
            }
            if(ekeyMap.containsKey(ras.ExternalKey__c)){
                if(ekeyMap.get(ras.ExternalKey__c) == 'true'){
                    continue;
                }
                i++;
            }else{
                ekeyMap.put(ras.ExternalKey__c, 'false');
                i = 1;
            }
            if(ras.Series_No__c <> i){
                rasShowTHList.add(ras);
                ekeyMap.put(ras.ExternalKey__c, 'true');
            }
        }
        if(rasShowCFList.size() > 0 ){
            haveErrCF_X = true;
        }
        if(rasShowTHList.size() > 0 ){
            haveErrTH_X = true;
        }
        Map<String,String> esnDMap = new Map<String,String>();
        Map<String,String> ekeyDMap = new Map<String,String>();
        List<Rental_Apply_Equipment_Set_Detail__c> raesdList = [Select Id,Name, Queue_Number__c,ExternalKey__c From Rental_Apply_Equipment_Set_Detail__c 
                                                where Cancel_Select__c = false  and  Queue_Number__c > 0 order by ExternalKey__c,Queue_Number__c];
        Integer ii = 1;
        for(Rental_Apply_Equipment_Set_Detail__c raesd:raesdList){
            String temp = raesd.ExternalKey__c + String.valueOf(raesd.Queue_Number__c);
            if(esnDMap.containsKey(temp)){
                raesDShowCFList.add(raesd);
            }else{
                esnDMap.put(temp,temp);
            }
            if(ekeyDMap.containsKey(raesd.ExternalKey__c)){
                if(ekeyDMap.get(raesd.ExternalKey__c) == 'true'){
                    continue;
                }
                ii++;
            }else{
                ekeyDMap.put(raesd.ExternalKey__c, 'false');
                ii = 1;
            }
            if(raesd.Queue_Number__c <> ii){
                raesDShowTHList.add(raesd);
                ekeyDMap.put(raesd.ExternalKey__c, 'true');
            }
        }
        if(raesDShowCFList.size() > 0 ){
            haveErrCF_D = true;
        }
        if(raesDShowTHList.size() > 0 ){
            haveErrTH_D = true;
        }
    }
    @TestVisible private void test() {
        Integer i = 0;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
    }
}