GWY
2022-05-21 a3460549533111815e7f73d6cef601a58031525d
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
public without sharing class AttachmentTriggerHandler {
 
    public static void fileCheck(List<Attachment> newList, Map<Id, Attachment> newMap, List<Attachment> oldList, Map<Id, Attachment> oldMap) {
        List<String> orderIdList = new List<String>();
        List<String> orderIdList2 = new List<String>();
        for (Attachment newAtt : newList) {
            String parentId = newAtt.parentId;
            String name = newAtt.Name;
            if (parentId.startsWith('801') && name.startsWith('ORDER-')) {
                orderIdList.add(newAtt.parentId);
            }
            if (parentId.startsWith('801')) {
                orderIdList2.add(newAtt.parentId);
            }
        }
 
        Map<String, String> isUploadMap = new Map<String, String>();
        Map<String, String> draftMap = new Map<String, String>();
        Map<String, String> submitMap = new Map<String, String>();
        Map<String, String> passMap = new Map<String, String>();
        if (orderIdList.size() > 0) {
            List<Order> orderList = [select id,IsUpload__c,ApproveStatus__c from Order where id = :orderIdList];
            for (Order o : orderList) {
                if (o.IsUpload__c) {
                    isUploadMap.put(o.Id, o.Id);
                }
                if (o.ApproveStatus__c == 'Draft' || o.ApproveStatus__c == 'Completed' || o.ApproveStatus__c == 'Reject') {
                    draftMap.put(o.Id, o.Id);
                }
            }
        }
        if (orderIdList2.size() > 0) {
            List<Order> orderList2 = [select id,IsUpload__c,ApproveStatus__c,IsOrderPassed__c from Order where id = :orderIdList2];
            for (Order o : orderList2) {
                if (o.ApproveStatus__c == 'Submit' || o.ApproveStatus__c == 'OrderSubmit') {
                    submitMap.put(o.Id, o.Id);
                }
                if (o.IsOrderPassed__c) {
                    passMap.put(o.Id, o.Id);
                }
            }
        }
        //新的获取人员简档ID 获取到的ID是15位
        // String profileId = UserInfo.getProfileId().substring(0, 15);
        String new_profileId = calendarUtil.getMemberProfileID(UserInfo.getUserId().subString(0,15));
        for (Attachment newAtt : newList) {
//            if (UserInfo.getProfileId() != System.Label.SystemAdmin && passMap.containsKey(newAtt.parentId)
//                && UserInfo.getProfileId() != System.Label.Business_department) {
//                newAtt.addError('合同批准后不能更改附件。');
//            }
             
            if (new_profileId != System.Label.Business_department && new_profileId != System.Label.SystemAdmin 
                && submitMap.containsKey(newAtt.parentId)) {
                newAtt.addError('合同被锁定,不能上传附件。');
            }
            if (isUploadMap.containsKey(newAtt.parentId)) {
                newAtt.addError('合同附件已经存在,不能上传多个。');
            }
            if (draftMap.containsKey(newAtt.parentId)) {
                newAtt.addError('请先审批完特殊条件再提交合同文件。');
            }
        }
    }
    //禁止上传多个收货确认单和装机确认单
    public static void fileCheck5(List<Attachment> newList, Map<Id, Attachment> newMap, List<Attachment> oldList, Map<Id, Attachment> oldMap) {
        List<String> lacIdList1 = new List<String>();
        List<String> lacIdList2 = new List<String>();
        List<String> lacIdList3 = new List<String>();
        List<String> lacIdList4 = new List<String>();
        for (Attachment newAtt : newList) {
            String parentId = newAtt.parentId;
            String name = newAtt.Name;
            if (parentId.startsWith('a0Q') && name.startsWith('收货确认-')) {
                lacIdList1.add(newAtt.parentId);
            }
            if(parentId.startsWith('a0Q') && name.startsWith('装机确认')){
                lacIdList2.add(newAtt.parentId);
            }
            if(parentId.startsWith('a0Q') && (name.startsWith('借用协议') || name.startsWith('借用单') || name.startsWith('DeliveryConfirmPDF'))){
                lacIdList3.add(newAtt.parentId);
            }
            if(parentId.startsWith('a0Q') && name.startsWith('转借确认')){
                lacIdList4.add(newAtt.parentId);
            }
 
        }
        Map<String,String> isUploadMap1 = new Map<String,String>();
        Map<String,String> isUploadMap2 = new Map<String,String>();
        Map<String,String> isUploadMap3 = new Map<String,String>();
        Map<String,String> isUploadMap4 = new Map<String,String>();
        if(lacIdList1.size()>0){
            List<loaner_application__c> lacList1 = [select id,Receipt_Attachment__c from loaner_application__c where id = :lacIdList1];
            for(loaner_application__c lac :lacList1){
                if(lac.Receipt_Attachment__c){
                    isUploadMap1.put(lac.Id, lac.Id);
                }
            }
        }
        if(lacIdList2.size()>0){
            List<loaner_application__c> lacList2 = [select id,Installation_Qualification_Attachment__c from loaner_application__c where id = :lacIdList2];
            for(loaner_application__c lac : lacList2){
                if(lac.Installation_Qualification_Attachment__c){
                    isUploadMap2.put(lac.Id, lac.Id);
                }
            }
        }
        if(lacIdList3.size()>0){
            List<loaner_application__c> lacList3 = [select id,Loaner_AgreementPDF__c from loaner_application__c where id = :lacIdList3];
            for(loaner_application__c lac : lacList3){
                if(lac.Loaner_AgreementPDF__c){
                    isUploadMap3.put(lac.Id, lac.Id);
                }
            }
        }
        if(lacIdList4.size()>0){
            List<loaner_application__c> lacList4 = [select id,Loaner_Confirm_Photo__c from loaner_application__c where id = :lacIdList4];
            for(loaner_application__c lac : lacList4){
                if(lac.Loaner_Confirm_Photo__c){
                    isUploadMap4.put(lac.Id, lac.Id);
                }
            }
        }
        for(Attachment newAtt : newList){
            if(isUploadMap1.containsKey(newAtt.parentId)){
                newAtt.addError('收货确认附件已经存在,不能上传多个。');
            }
            if(isUploadMap2.containsKey(newAtt.parentId)){
                newAtt.addError('装机确认附件已经存在,不能上传多个。');
            }
            if(isUploadMap3.containsKey(newAtt.parentId)){
                newAtt.addError('借用协议附件已经存在,不能上传多个。');
            }
            if(isUploadMap4.containsKey(newAtt.parentId)){
                newAtt.addError('转借确认附件已经存在,不能上传多个。');
            }
        }
 
    }
    //装机确认后,禁止删除确认单
    public static void fileCheck6(List<Attachment> newList, Map<Id, Attachment> newMap, List<Attachment> oldList, Map<Id, Attachment> oldMap) {
 
        List<String> lacIdList = new List<String>();
        List<String> lacIdList1 = new List<String>();
        for(Attachment oldAtt : oldList){
            String parentId = oldAtt.parentId;
            String name = oldAtt.Name;
            if(parentId.startsWith('a0Q') && name.startsWith('装机确认')){
                lacIdList.add(parentId);
            }
            if(parentId.startsWith('a0Q') && (name.startsWith('借用协议') || name.startsWith('借用单') || name.startsWith('DeliveryConfirmPDF'))){
                lacIdList1.add(parentId);
            }
        }
 
        Map<String,String> deleteMap = new Map<String,String>();
        Map<String,String> deleteMap1 = new Map<String,String>();
        if(lacIdList.size()>0){
            List<loaner_application__c> lacList = [select id,HP_Received_Sign_Date__c from loaner_application__c where id = :lacIdList];
            for(loaner_application__c lac : lacList){
                if(lac.HP_Received_Sign_Date__c != null){
                    deleteMap.put(lac.id,lac.id);
                }
            }
        }
        if(lacIdList1.size() >0 ){
            List<loaner_application__c> lacList1 = [select id,Bollow_Date__c from loaner_application__c where id = :lacIdList1];
            for(loaner_application__c lac: lacList1){
                if(lac.Bollow_Date__c != null){
                    deleteMap1.put(lac.id,lac.id);
                }
            }
        }
        for(Attachment oldAtt : oldList){
            if(deleteMap.containsKey(oldAtt.parentId)){
                oldAtt.addError('已装机确认,不能删除装机确认附件');
            }
            if(deleteMap1.containsKey(oldAtt.parentId)){
                oldAtt.addError('已出库指示,不能删除借用协议附件');
            }
        }
 
    }
 
    public static void uploadContract(List<Attachment> newList, Map<Id, Attachment> newMap, List<Attachment> oldList, Map<Id, Attachment> oldMap) {
        List<Order> orderList = new List<Order>();
       
        for (Attachment newAtt : newList) {
            String parentId = newAtt.parentId;
            String name = newAtt.Name;
            if (parentId.startsWith('801') && name.startsWith('ORDER-')) {
                Order ord = new Order();
                ord.Id = parentId;
                //ord.Name = name.substring(6, name.indexOf('.'));
                ord.Upload_IsChanged__c = true;
                ord.IsUpload__c = true;
 
                orderList.add(ord);
            }
        }
 
        if (orderList.size() > 0) {
            update orderList;
        }
 
    }
 
    // Added by HANCHAO 20170123
    public static void AfterPassUpload(List<Attachment> newList, Map<Id, Attachment> newMap, List<Attachment> oldList, Map<Id, Attachment> oldMap) {
        List<Order> orderList = new List<Order>();
 
        for (Attachment newAtt : newList) {
            String parentId = newAtt.parentId;
            if (parentId.startsWith('801')) {
                Order ord1 = [select id,IsUpload__c,ApproveStatus__c,IsOrderPassed__c from Order where id = :parentId];
                if (ord1.IsOrderPassed__c) {
                    Order ord = new Order();
                    ord.Id = parentId;
                    ord.AfterPassAttachmentUpload__c = true;
                    orderList.add(ord);
                }
            }
        }
 
        if (orderList.size() > 0) {
            update orderList;
        }
 
    }
    //添加确认单时添加对应标记
    public static void fileCheck4(List<Attachment> newList, Map<Id, Attachment> newMap, List<Attachment> oldList, Map<Id, Attachment> oldMap){
 
        List<loaner_application__c> lacList = new List<loaner_application__c>();
 
        for (Attachment newAtt : newList) {
            String parentId = newAtt.parentId;
            String name = newAtt.Name;
            //判断是否上传收货确认附件和安装确认附件
            if(parentId.startsWith('a0Q')){
                if(name.startsWith('收货确认-')){
                    loaner_application__c lac = new loaner_application__c();
                    lac.id = parentId;
 //                    [select id,Receipt_Attachment__c from loaner_application__c where id = :parentId];
                    lac.Receipt_Attachment__c = true;
                    lacList.add(lac);
                }
                if(name.startsWith('装机确认')){
                    loaner_application__c lac =new loaner_application__c();
                    lac.id = parentId;
 //                   [select id,Installation_Qualification_Attachment__c from loaner_application__c where id = :parentId];
                    lac.Installation_Qualification_Attachment__c = true;
                    lacList.add(lac);  
                }
                if(name.startsWith('借用协议') || name.startsWith('借用单') || name.startsWith('DeliveryConfirmPDF')){
                    loaner_application__c lac = new loaner_application__c();
                    lac.id = parentId;
                    lac.Loaner_AgreementPDF__c = true;
                    lacList.add(lac);
                }
                 if(name.startsWith('转借确认')){
                    loaner_application__c lac = new loaner_application__c();
                    lac.id = parentId;
                    lac.Loaner_Confirm_Photo__c = true;
                    lacList.add(lac);
                }
            }
        }
 
 
        if(lacList.size() > 0){
            try{
                update lacList;
            }catch(Exception ex){
                newList[0].addError(ex.getMessage().mid((ex.getMessage().indexOf('first error:') + 12),ex.getMessage().length()));
            }
        }
 
    }
 
    public static void fileCheck2(List<Attachment> newList, Map<Id, Attachment> newMap, List<Attachment> oldList, Map<Id, Attachment> oldMap) {
        List<String> orderIdList = new List<String>();
 
        for (Attachment oldAtt : oldList) {
            String parentId = oldAtt.parentId;
            if (parentId.startsWith('801')) {
                orderIdList.add(oldAtt.parentId);
            }
        }
 
        Map<String, String> submitMap = new Map<String, String>();
        Map<String, Order> passMap = new Map<String, Order>();
 
        if (orderIdList.size() > 0) {
            List<Order> orderList = [select id,IsUpload__c,ApproveStatus__c,IsOrderPassed__c, Is_Already_Splited__c from Order where id = :orderIdList];
            for (Order o : orderList) {
                if (o.ApproveStatus__c == 'Submit' || o.ApproveStatus__c == 'OrderSubmit') {
                    submitMap.put(o.Id, o.Id);
                }
                if (o.IsOrderPassed__c) {
                    passMap.put(o.Id, o);
                }
            }
        }
        //新的获取人员简档ID 获取到的ID是15位
        // String profileId = UserInfo.getProfileId().substring(0, 15);
        String new_profileId = calendarUtil.getMemberProfileID(UserInfo.getUserId().subString(0,15));
        for (Attachment oldAtt : oldList) {
            /*if (UserInfo.getProfileId() != System.Label.SystemAdmin && submitMap.containsKey(oldAtt.parentId)) {
                oldAtt.addError('合同被锁定,不能更改附件。');
            }
            if (UserInfo.getProfileId() != System.Label.SystemAdmin && passMap.containsKey(oldAtt.parentId)
                && UserInfo.getProfileId() != System.Label.Business_department && passMap.get(oldAtt.parentId).Is_Already_Splited__c == false) {
                oldAtt.addError('合同批准后不能更改附件。');
            }*/
            if (new_profileId != System.Label.SystemAdmin
                && submitMap.containsKey(oldAtt.parentId)) {
                oldAtt.addError('合同被锁定,不能更改附件。');
            }
            if (new_profileId != System.Label.SystemAdmin && passMap.containsKey(oldAtt.parentId)
                && new_profileId != System.Label.Business_department && passMap.get(oldAtt.parentId).Is_Already_Splited__c == false) {
                oldAtt.addError('合同批准后不能更改附件。');
            }
        }
    }
 
    public static void fileCheck3(List<Attachment> newList, Map<Id, Attachment> newMap, List<Attachment> oldList, Map<Id, Attachment> oldMap) {
        List<String> orderIdList = new List<String>();
 
        for (Attachment newAtt : newList) {
            String parentId = newAtt.parentId;
            if (parentId.startsWith('801')) {
                orderIdList.add(newAtt.parentId);
            }
        }
 
        Map<String, String> submitMap = new Map<String, String>();
        Map<String, Order> passMap = new Map<String, Order>();
 
        if (orderIdList.size() > 0) {
            List<Order> orderList = [select id,IsUpload__c,ApproveStatus__c,IsOrderPassed__c, Is_Already_Splited__c from Order where id = :orderIdList];
            for (Order o : orderList) {
                if (o.ApproveStatus__c == 'Submit' || o.ApproveStatus__c == 'OrderSubmit') {
                    submitMap.put(o.Id, o.Id);
                }
                if (o.IsOrderPassed__c) {
                    passMap.put(o.Id, o);
                }
            }
        }
        //新的获取人员简档ID 获取到的ID是15位
        // String profileId = UserInfo.getProfileId().substring(0, 15);
        String new_profileId = calendarUtil.getMemberProfileID(UserInfo.getUserId().subString(0,15));
        /*for (Attachment newAtt : newList) {
            if (UserInfo.getProfileId() != System.Label.SystemAdmin && submitMap.containsKey(newAtt.parentId)) {
                newAtt.addError('合同被锁定,不能更改附件。');
            }
            if (UserInfo.getProfileId() != System.Label.SystemAdmin && passMap.containsKey(newAtt.parentId)
                && UserInfo.getProfileId() != System.Label.Business_department && passMap.get(newAtt.parentId).Is_Already_Splited__c == false) {
                newAtt.addError('合同批准后不能更改附件。');
            }
        }*/
        for (Attachment newAtt : newList) {
            if (new_profileId != System.Label.SystemAdmin  
                && submitMap.containsKey(newAtt.parentId)) {
                newAtt.addError('合同被锁定,不能更改附件。');
            }
            if (new_profileId != System.Label.SystemAdmin && passMap.containsKey(newAtt.parentId)
                && new_profileId != System.Label.Business_department && passMap.get(newAtt.parentId).Is_Already_Splited__c == false) {
                newAtt.addError('合同批准后不能更改附件。');
            }
        }
    }
 
    public static void deleteContract(List<Attachment> newList, Map<Id, Attachment> newMap, List<Attachment> oldList, Map<Id, Attachment> oldMap) {
        List<Order> orderList = new List<Order>();
 
        for (Attachment oldAtt : oldList) {
            String parentId = oldAtt.parentId;
            String name = oldAtt.Name;
            if (parentId.startsWith('801') && name.startsWith('ORDER-')) {
                Order ord = new Order();
                ord.Id = parentId;
                //ord.Name = '';
                ord.Upload_IsChanged__c = true;
                ord.IsUpload__c = false;
 
                orderList.add(ord);
            }
        }
 
        if (orderList.size() > 0) {
            update orderList;
        }
    }
 
    //删除确认单时取消对应标记;
    public static void deleteconfirm(List<Attachment> newList, Map<Id, Attachment> newMap, List<Attachment> oldList, Map<Id, Attachment> oldMap){
        List<loaner_application__c> lacList = new List<loaner_application__c>();
 
        for (Attachment oldAtt : oldList) {
            String parentId = oldAtt.parentId;
            String name = oldAtt.Name;
            //判断是否删除收货确认附件和安装确认附件
            if(parentId.startsWith('a0Q')){
                if(name.startsWith('收货确认-')){
                    loaner_application__c lac = new loaner_application__c();
                    lac.id = parentId;
//                    [select id,Receipt_Attachment__c from loaner_application__c where id = :parentId];
                    lac.Receipt_Attachment__c = false;
                    lacList.add(lac);
                }
                if(name.startsWith('装机确认')){
                    loaner_application__c lac = new loaner_application__c();
                    lac.id = parentId;
//                    [select id,Installation_Qualification_Attachment__c from loaner_application__c where id = :parentId];
                    lac.Installation_Qualification_Attachment__c = false;
                    lacList.add(lac);  
                }
                if(name.startsWith('借用协议') || name.startsWith('借用单') || name.startsWith('DeliveryConfirmPDF')){
                    loaner_application__c lac = new loaner_application__c();
                    lac.id = parentId;
                    lac.Loaner_AgreementPDF__c = false;
                    lacList.add(lac);
                }
                if(name.startsWith('转借确认')){
                    loaner_application__c lac = new loaner_application__c();
                    lac.id = parentId;
                    lac.Loaner_Confirm_Photo__c = false;
                    lacList.add(lac);
                }
            }
        }
        if(lacList.size() > 0){
            update lacList;
        }        
    }
 
    //业务活动上传附件完成之后将附件克隆至相关联的用户信息上面
    public static void AfterUploadToUserFaultInfo(List<Attachment> newList, Map<Id, Attachment> newMap, List<Attachment> oldList, Map<Id, Attachment> oldMap) {
        List<String> selectBAIdList = new List<String>();
        String firstThreeDigitCode= System.label.FirstThreeDigitCode;
        for (Attachment newAtt : newList) {
            String parentId = newAtt.parentId;
            if (parentId.startsWith(firstThreeDigitCode)) {
                selectBAIdList.add(parentId);
            }
        }
        
        if (selectBAIdList.size() > 0) {
            List<BusinessActivity__c> businessActivityList = TSRepairUtil.GetBusinessActivityList(null,null, selectbaIdList,null,null,'');
 
            String userFaultInfoId = businessActivityList[0].User_FaultInfo__c;
            System.debug('userFaultInfoId---->'+userFaultInfoId);
            if (String.isNotBlank(userFaultInfoId)) {
                    
                    // 获取用户/故障信息的附件
                    List<String> selectUfIdList = new List<String>();
                    selectUfIdList.add(userFaultInfoId);
                    List<Attachment> ufAttachmentList = TSRepairUtil.GetAttachmentList(selectUfIdList);
 
                    if (ufAttachmentList.size() >0){
                        //删除用户/故障信息的附件
                        delete ufAttachmentList;
                        
                    }
 
                    //将业务活动下的附件克隆至 用户/故障信息
                    TSRepairUtil.insertattachmentCloneList(selectBAIdList,userFaultInfoId);
                    
                }
 
        }
    }
    //王鹏伟 贸易管理客户申请表 合同已提交 不允许修改贸易管理客户申请表附件 
    public static void updateTradeCustomerManagerFile(List<Attachment> newList, Map<Id, Attachment> newMap, List<Attachment> oldList, Map<Id, Attachment> oldMap){
        for(Attachment accach : newList){
            String parentId = accach.parentId;
            String tradeCustomerManagerStart = System.label.TradeCustomerManagerStart;
            if(parentId.startsWith(tradeCustomerManagerStart)){
                TradeCustomerManager__c trade = [select Id,order__c,isHaveLink__c from TradeCustomerManager__c where Id =: parentId];
                if(trade!=null){
                    Order order = [select Id,applicationForm__c,ApproveStatus__c from Order where id=:trade.order__c];
                    if(order !=null){
                        if(order.ApproveStatus__c == 'OrderPass' || order.ApproveStatus__c == 'OrderSubmit'){
                            accach.addError('合同已提交,申请表附件不可修改!');
                            return;
                        }
                    }
                }
            }
        }
    }
    //王鹏伟判断是否是 贸易管理客户申请表 下的文件 如果是
    public static void DeleteTradeCustomerManagerFile(List<Attachment> newList, Map<Id, Attachment> newMap, List<Attachment> oldList, Map<Id, Attachment> oldMap){
        for(Attachment accach : oldList){
            String parentId = accach.parentId;
            String tradeCustomerManagerStart = System.label.TradeCustomerManagerStart;
            if(parentId.startsWith(tradeCustomerManagerStart)){
                TradeCustomerManager__c trade = [select Id,order__c,isHaveLink__c from TradeCustomerManager__c where Id =: parentId];
                if(trade!=null){
                    Order order = [select Id,applicationForm__c,ApproveStatus__c from Order where id=:trade.order__c];
                    if(order!=null){
                        if(order.ApproveStatus__c == 'OrderPass' || order.ApproveStatus__c == 'OrderSubmit'){
                            accach.addError('合同已提交,申请表附件不可删除!');
                            return;
                        }
                        if(order!=null &&(accach.Name.startsWith('军事')||(accach.Name.startsWith('个人信息') && trade.isHaveLink__c == '是'))){
                            order.applicationForm__c = false;
                            update order;
                        }
                    }
                }
            }
        }
    }
    //王鹏伟新加判断  贸易管理客户申请表 一个申请表下只能有一份文件名以军事或个人信息开头的文件!
    public static void UploadTradeCustomerManagerFile(List<Attachment> newList, Map<Id, Attachment> newMap, List<Attachment> oldList, Map<Id, Attachment> oldMap){
         for(Attachment accach : newList){
            String parentId = accach.parentId;
            String tradeCustomerManagerStart = System.label.TradeCustomerManagerStart;
            if(parentId.startsWith(tradeCustomerManagerStart)){
                List<Attachment> fileList = [select Id,Name from Attachment where ParentId =:parentId];
                if(fileList!=null && fileList.size()!=0){
                    for(Attachment acc : fileList){
                        if(acc.Name.substring(0,2).equals('军事') && accach.Name.startsWith('军事')){
                            accach.addError('一个贸易管理客户申请表下,只能有一份文件名以军事开头的文件!');
                            return;
                        }
                        if(acc.Name.startsWith('个人信息') && accach.Name.startsWith('个人信息')){
                            accach.addError('一个贸易管理客户申请表下,只能有一份文件名以个人开头的文件!');
                            return;
                        }
                    }
                }
            }
        }
    }
}