liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
/*
    TestClass
    RentalFixtureManage1Test
    RentalFixtureManage3Test
    RentalFixtureManage9Test
    RentalFixtureManage10Test
 */
public with sharing class EquipmentSetSRList2Controller {
    public List<Rental_Apply_Equipment_Set__c> resList { get; set; }
    public String sr_open { get; set; }
    public String sr_apply_no { get; set; }
    public String sr_id { get; set; }
    public String sr_type { get; set; }
    public List<SelectOption> typeList {get; set;}
    public String selectedType {get; set;}
    private String Id;
    public Integer getResListSize() {
        return resList.size();
    }
 
    public EquipmentSetSRList2Controller() {
//        Apexpages.currentPage().getHeaders().put('X-UA-Compatible', 'IE=8');
        Id = ApexPages.currentPage().getParameters().get('id');
        sr_type = ApexPages.currentPage().getParameters().get('type');
        sr_open = ApexPages.currentPage().getParameters().get('open');
    }
 
    public Pagereference init() {
        resList = new List<Rental_Apply_Equipment_Set__c>();
        initTypeList();
 
        if (Id != null) {
            resList = [select Rental_Apply__r.Name, First_RAESD_Model_No_F__c, First_RAESD__r.SerialNumber_F__c, First_RAESD__r.Fixture_QRCode_F__c, RAES_Status__c
                    from Rental_Apply_Equipment_Set__c
                    where Rental_Apply__r.Name = :id order by Name
                    //AND Cancel_Select__c = false
                    ];
            if (resList.size() > 0) {
                sr_apply_no = resList[0].Rental_Apply__r.Name;
                sr_id = resList[0].Rental_Apply__r.Name;
            } else {
                List<Rental_Apply_Equipment_Set_Detail__c> raesdList = [select Id from Rental_Apply_Equipment_Set_Detail__c where Fixture_QRCode_F__c = :id
                              //and Cancel_Select__c = False
                            ];
                Set<Id> raesdSet = new Set<Id>();
                if (raesdList.size() > 0) {
                    for (Rental_Apply_Equipment_Set_Detail__c raesd : raesdList) {
                        raesdSet.add(raesd.Id);
                    }
                }
                resList = [select Id, Rental_Apply__c, Rental_Apply__r.Name, First_RAESD_Model_No_F__c, First_RAESD__r.SerialNumber_F__c, First_RAESD__r.Fixture_QRCode_F__c, RAES_Status__c
                        from Rental_Apply_Equipment_Set__c
                       where (First_RAESD__c in :raesdSet
                                or ((First_RAESD__r.Canceled__c in :raesdSet or First_RAESD__r.Canceled__r.Canceled__c in :raesdSet)
                                        and Rental_Apply__r.ShelfUp_ng_num__c <> 0
                                )
                            )
                         and Rental_Apply__r.RA_Status__c <> :FixtureUtil.raStatusMap.get(FixtureUtil.RaStatus.Wan_Liao.ordinal())
                         and Rental_Apply__r.RecordType.DeveloperName != 'AgencyRequest'
                       order by Name
                    ];
                if (resList.size() > 0) {
                    sr_apply_no = resList[0].Rental_Apply__r.Name;
                    sr_id = resList[0].Id;
                }
                else {
                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '备品不存在'));
                    List<Asset> assList = [SELECT Id FROM Asset WHERE Fixture_QRCode__c=:Id LIMIT 1];
                    if(!assList.isEmpty()) {
                        return new Pagereference('/apex/TransferEquipmentSetSRList?id=' + id);
                    }
                }
            }
 
        }
        return null;
    }
 
    private void initTypeList(){
        typeList = new List<SelectOption>();
        typeList.add(new SelectOption('无','无'));
        typeList.add(new SelectOption('下架', '下架'));
        typeList.add(new SelectOption('出库检测', '出库检测'));
        typeList.add(new SelectOption('发货','发货'));
        typeList.add(new SelectOption('回寄','回寄'));
        typeList.add(new SelectOption('欠品','欠品'));
        typeList.add(new SelectOption('回收检测','回收检测'));
        typeList.add(new SelectOption('上架', '上架'));
        System_UserSetting__c config = System_UserSetting__c.getInstance(UserInfo.getUserId());
        selectedType = config.RAESD_Action_Type__c;
        if (String.isBlank(selectedType)){
            selectedType = '无';
        }
 
    }
    public void setType(){
        if (selectedType != '无' && selectedType != null ){
            System_UserSetting__c config = System_UserSetting__c.getInstance(UserInfo.getUserId());
            config.RAESD_Action_Type__c = selectedType;
            FixtureUtil.withoutUpsertObjects(new System_UserSetting__c[]{config});
        }
 
    }
 
    //// 出库
 //           //todo エラーか、0件か
 //           if (SR_status == 'Shippment') {
 //               if (es.Shipment_request_time__c == null || es.Arrival_in_wh__c) {
 //                   ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info, '备品没有出库指示'));
 //                   saveBtnDisabled = true;
 //                   return null;
 //               }
 //               if(Rac.repair__r.Repair_Final_Inspection_Date__c<Date.today()){
 //                   ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info, '维修检测已完成,不能出库'));
 //                   saveBtnDisabled = true;
 //                   return null;
 //               }
 //               if (es.Shippment_loaner_time__c != null) {
 //                   ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info, '备品已经出库'));
 //                   saveBtnDisabled = true;
 //                   return null;
 //               }
 //               if (es.cancel_after_loaner_arranged__c == true) {
 //                   ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info, '备品借出申请已经取消,不能出库'));
 //                   saveBtnDisabled = true;
 //                   return null;
 //               }
 //               if(Ra_c.Cancel_Date__c!=null){
 //                   ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info, '分配已取消,不能出库'));
 //                   saveBtnDisabled = true;
 //                   return null;
 //               }
 //               if(Rac.Campaign__r.Status == '取消'){
 //                 ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info, '学会状态取消,备品不可操作'));
 //                 saveBtnDisabled = true;
 //                 return null;
 //               }
 //               //***********************20161130本藩上线暂不作对应,禁用********************************//
 //               if(Rac.repair__r.Repair_Final_Inspection_Date__c!=null&&Rac.repair__c!=null){
 //                   ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info, '最终检测日不为空,不能出库'));
 //                   saveBtnDisabled = true;
 //                   return null;
 //               }
 //               if(Rac.repair__r.Repair_Shipped_Date__c!=null&&Rac.repair__c!=null){
 //                   ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info, 'RC修理品返送日不为空,不能出库'));
 //                   saveBtnDisabled = true;
 //                   return null;
 //               }
 //               if(Rac.repair__r.Return_Without_Repair_Date__c!=null&&Rac.repair__c!=null){
 //                   ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info, '未修理归还日不为空,不能出库'));
 //                   saveBtnDisabled = true;
 //                   return null;
 
 //               }
 //               //***********************20161130本藩上线暂不作对应,禁用********************************//
 //               if (es.Return_to_wh_staff__c == null) {
 //                   es.Return_to_wh_staff__c = user.Id;
 //                   es.Return_to_wh_staff__r = user;
 //               }
 //               if (Step_status == null) {
 //                   Step_status = '发货';
 //                   if (es.Inspection_result_notOK_cnt__c > 0) {
 //                       Step_status = '发货前';
 //                   }
 //               }
 //           }
 //           // 入库
 //           if (SR_status == 'Received') {
 //               if (es.Shippment_loaner_time__c == null && es.cancel_after_loaner_arranged__c == false && es.Arrival_wh_time2__c == null) {
 //                   //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '备品没有出库'));
 //                   //saveBtnDisabled = true;
 //                   //return null;
 //                   // 備品センターは下架前であれば分配取消、下架以降であれば上架を行う
 //                   ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info, '备品没有出库'));
 //               }
 //               if (es.Arrival_wh_time2__c != null) {
 //                   ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info, '备品已回库上架完了'));
 //                   saveBtnDisabled = true;
 //                   return null;
 //               }
 //               if (es.Fedex_number__c != null && es.Fedex_number__c != '' && (es.Return_Fedex_number__c == null || es.Return_Fedex_number__c == '')) {
 //                   ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info, '备品没有寄回'));
 //                   saveBtnDisabled = true;
 //                   return null;
 //               }
 //               if(Step_status == '回库'){
 //                   if(es.Wait_for_Repair__c !=0 || es.Wait_for_Abandon__c !=0 ){
 //                       //主机维修/废弃
 //                       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info, '主机维修/废弃时,不能回库确认操作'));
 //                       //ErrorMessage = '主机维修/废弃时,不能回库确认操作';
 //                       saveBtnDisabled = true;
 //                   }
 //               }
 //               if(es.MissingCntSerial__c !=0){
 //                   //主机欠品
 //                   ReturnRefuse = false;
 //                   ErrorMessage = '主机异常,无法上架';
 //                   saveBtnDisabled = false;
 //               }
 //               /*if(es.CDS_complete__c ==false){
 //                   saveBtnDisabled = false;
 //                   CDSFinished = 'CDS未完成';
 //               }*/
 //               if(es.RepairCntSerial__c !=0){
 //                   //主机维修
 //                   ReturnRefuse = false;
 //                   ErrorMessage = '主机维修,无法上架';
 //                   saveBtnDisabled = false;
 //               }
 //               //if(Rac.Campaign__r.Status == '取消'){
 //               //  ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info, '学会状态取消,备品不可操作'));
 //               //  saveBtnDisabled = true;
 //               //  return null;
 //               //}
 
 //               //***********************20161130本藩上线暂不作对应,禁用********************************//
 //               //if(Rac.repair__r.Repair_Final_Inspection_Date__c!=null&&Rac.repair__c!=null&&Ra_c.RAES_Status__c!='取消分配'){
 //               //    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info, '最终检修日不为空,不能回库'));
 //               //    saveBtnDisabled = true;
 //               //    return null;
 //               //}
 //               //if(Rac.repair__r.Repair_Shipped_Date__c!=null&&Rac.repair__c!=null&&Ra_c.RAES_Status__c!='取消分配'){
 //               //    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info, 'RC修理品返送日不为空,不能回库'));
 //               //    saveBtnDisabled = true;
 //               //    return null;
 //               //}
 //               //if(Rac.repair__r.Return_Without_Repair_Date__c!=null&&Rac.repair__c!=null&&Ra_c.RAES_Status__c!='取消分配'){
 //               //    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info, '未修理归还日不为空,不能回库'));
 //               //    saveBtnDisabled = true;
 //               //    return null;
 
 //               //}
 //               //***********************20161130本藩上线暂不作对应,禁用********************************//
 //              /* if(es.RepairAbandonCntSerial__c!=0){
 //                   //主机等待维修,或者废弃
 //                   ReturnRefuse = false;
 //                   ErrorMessage = '主机等待维修,或者废弃,无法上架';
 //                   saveBtnDisabled = false;
 //               } */
 //               if(es.Wait_for_Repair__c!=0){
 //                   ReturnRefuse = false;
 //                   ErrorMessage = '主机等待维修,无法上架';
 //                   saveBtnDisabled = false;
 //               }
 //               if(es.Wait_for_Abandon__c!=0){
 //                   ReturnRefuse = false;
 //                   ErrorMessage = '主机等待废弃,无法上架';
 //                   saveBtnDisabled = false;
 //               }
 //               //20161114对应,回寄确认者===》》》回库确认者
 //               //更新时机错误
 //               /*
 //               if (es.Received_confirmation_staff__c == null) {
 
 //                   es.Received_confirmation_staff__c = user.Id;
 //                   es.Received_confirmation_staff__r = user;
 //               }*/
 //               //20161114对应,回寄确认者===》》》回库确认者
 //               if (Step_status == null) {
 //                   if (es.Lost_item_check__c != 'OK') {
 //                       Step_status = '回寄';
 //                   } else {
 //                       Step_status = 'CDS';
 //                   }
 //               }
 
 //               //if ((es.Lost_item_check_time__c == null || es.MissingCnt__c > 0) && Step_status != '回寄') {
 //               if (es.LostItemCheckCnt__c < es.contents_number__c && es.Fedex_number__c != null && Step_status != '回寄') {
 //                   ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Info, '请先进行欠品确认'));
 //                   saveBtnDisabled = true;
 //                   return null;
 //               }
 //           }
}