张宇恒
2022-05-07 45680dc03886f98506ed413b0be2b748eb75ffb2
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
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
public without sharing class NFM603Controller {
 
    private static final String LOG_TYPE = 'NFM603';
    // private static final String API = '/admin/api/scd/save';
    private static final String API = '/admin/api/repair/save';
 
    // 2022-05-05      zyh     update      start
    private static List < BatchIF_Log__c > logList = new List < BatchIF_Log__c > ();
    private static List < BatchIF_Log__c > rowList = new List < BatchIF_Log__c > ();
    private static Map < Id,BatchIF_Log__c > logMap = new Map < Id,BatchIF_Log__c > ();
    // 2022-05-05      zyh     update      end
    public static Integer status;
    public static String message;
    public class RepairOrderInfo {
        //修理信息
        public String repairOrderNo; //报修单号
        public String repairOrderNo2; //报修子单号
        public String SAPrepairNo; //SAP修理单号(new)
        public String repairNo; //修理单号
        public String hospitalCd; //医院编号
        public String strategicDepartmenCd; //战略科室编码
        public String departmentCd; //科室编码
        public String region; //大区
        public String province; //省市
        public String city; //市
        public String repairApplicant; //修理委托人
        public String repairApplicantID; //修理委托人统一ID(new)===预留
    
        public String FSERepairOrderCreateDate; //FSE申请修理时间(new)
        public String SAPRepairOrderCreateDate; //SAP申请修理时间(new)
        public String equipmentModel; //设备型号
        public String equipmentCd; //机身编码
        public String On_site_repair; //服务方式
        public String ContractName; //维修合同名称(new)
        public String ContractData; //维修合同记录类型(new)
        public String ContractNo; //维修合同号码
        public String ContractStartDate; //维修合同开始日
        public String ContractEndDate; //维修合同结束日
        public String MultiYearContractName; //多年保合同名称(new)
        public String MultiYearContractNo; //多年保合同编号
        public String MultiYearContractStartDate; //多年保合同开始日
        public String MultiYearContractEndDate; //多年保合同结束日
        public String MultiYearContractData; //多年保合同记录类型(new)
        public Boolean isRepairWarrantyObj; //再修理保修对象
        public String RepairType; //修理区分-------------------
        public String QuotationGread; //报价等级(new)
        public String detectionResult; //检测结果
        public String cus_dn; //DN号
        //修理增加OTS运单号字段 thh 20220308 start
        public String OTSRepairOrder;
        //修理增加OTS运单号字段 thh 20220308 end
 
        //送修物流
        public String deliveryLogisticsMode; //送修物流方式
        public String engineerSendDate; //工程师修理品寄送日
        public String deliveryLogisticsNo; //送修物流单号
        public String DeliveryLogisticsAnnotation; //送修物流信息备注
        public String returnLogisticsMode; //返送物流方式
        public String returnLogisticsNo; //返送物流单号
        public String returnLogisticsRemark; //返送物流备注信息
        public String returnStage; //维修品返送所处阶段
        public String returnLogisticsSendTime; //返送物流发送时间+++++++++++++
        public String returnLogisticsReceiveTime; //返送物流签收时间++++++++++++
        //服务进程-进修
        public String repairproductsRevDate; //故障品接收日
        public String FSErepairApplyDate; //FSE修理申请日
        public String logisticsSendDate; //物流发送日
        public String logisticsReceiveDate; //物流接收日
        public String SAPrepairApplyDate; //SAP修理申请日
        public String RCacceptanceDate; //修理品RC受理日
        public String inspectionDate; //修理检测日
        public String FirstQuotationDate; //初次报价日
        public String planQuotationDate; //计划上门报价日
        public String ActualQuotationDate; //实际上门报价日
        public String quotationDate; //报价日
        public String priceApprovalDate; //减价申请批准日
        public Decimal finalQuotationPrice; //最终报价金额-----------------
        public String userAgreeDAte; //用户同意日
        public String partsCompleteDate; //零件齐备完毕日
        public String repairStartDate; //修理开始日
        public String repairCompleteExpectedDate; //修理完成预计日
        public String repairCompleteDate; //修理完成日
        public String finalTestDate; //最终检测日
        public String RCreturnDate; //RC修理品返送日
        public String ReturnsProductWay; //返品方式
        public String officeLogisticsReceiveDate; //办事处物流接收日
        public String invoiceDate; //开发票日
        public String userReturnDate; //修理品用户返送日
        public String acceptanceFormSendDate; //验收单现场寄送日
        public String acceptanceFormReceivedDate; //验收单收到日
        public String invoiceReceiveDate; //发票接收日
        public String latestPayDate; //最新回款日
        public String payCompleteDate; //回款完毕日
        public String incomeReckoninDate; //收入计入日
        public String abandonPayDate; //放弃回款日
        public String cancelRepairDate; //修理取消日
        public String repairOrderCompleteDate; //修理单完成日
        public Boolean applySpareEquip; //是否申请备品
        public String supplySpareEquip; //是否提供备品
        public FaultDesc[] FaultDesc;
        public SparePartsLendingRecord[] SparePartsLendingRecord;
        //===================================================
        public String RcSorcDate; //RC转SORC日
        public String SorcAcceptDate; //SORC受理日
        public String SorcOgzDate; //SORC转OGZ日
        public String OgzAcceptDate; //OGZ受理日
 
    }
    public class FaultDesc {
        //故障描述
        public String repairPosition; //修理部位
        public String faultDescription; //故障描述
        //修理内容
        public String repairContentDesc; //修理内容描述
    }
    public class SparePartsLendingRecord {
        //备品出借记录
        public String spareEquipapplicationNo; //备品申请编号
        public String spareEquipLendingDate; //备品出借日期 
        public String spareEquipMode; //出借备品型号
    }
    @future(callout = true)
    public static void callout(String iflog_Id, List < String > repairOrderIdList) {
        //BatchIF_Log__c iflog = [Select Id, Name, Log__c, ErrorLog__c from BatchIF_Log__c where Id = :iflog_Id];
        String sql = 'Select Id, Name, Log__c, ErrorLog__c from BatchIF_Log__c where Id = \'' + iflog_Id + '\'';
        List < BatchIF_Log__c > iflogs = DataBase.query(sql);
        if (iflogs == null || iflogs.size() == 0) {
            executefuture(null, repairOrderIdList);
        } else {
            executefuture(iflogs.get(0), repairOrderIdList);
        }
 
    }
 
    public static void executefuture(BatchIF_Log__c iflog, List < String > repairOrderIdList) {
        Datetime nowDT = Datetime.now();
        String nowStr = nowDT.format('yyyyMMddHHmmss');
        if (iflog != null) {
            iflog.ErrorLog__c = '';
        } else {
            iflog = new BatchIF_Log__c();
            iflog.Type__c = LOG_TYPE;
            iflog.ErrorLog__c = '';
            iflog.Log__c = 'callout start \n';
            iflog.MessageGroupNumber__c = nowStr;
        }
        List < RepairOrderInfo > repairs = new List < RepairOrderInfo > ();
        List < RepairOrderInfo > repairs1 = new List < RepairOrderInfo > ();
        BatchIF_Log__c rowData = null;
        List < Repair__c > repairList = new List < Repair__c > ();
        if (repairOrderIdList != null && repairOrderIdList.size() > 0) {
            repairList = [select id, Name, 
                RepairSubOrder__r.RepairOrderNo__c,
                RepairSubOrder__r.RepairSubOrderNo__c,
                Hospital__r.Management_Code__c,
                SAP_Service_Repair_No__c,
                Account__r.Management_Code__c,
                Department_Name__c,
                Account_Management_Code__c,
                Hospital__r.Salesdepartment_HP__c,
                State_Hospital__c,
                Hospital__r.City_Master__r.Name,
                Incharge_Staff__r.Employee_No__c,
                CreatedBy.Employee_No__c,
                FSE_ApplyForRepair_time__c,
                SAP_Transfer_time__c,
                Delivered_Product__r.Product_Name__c,
                Delivered_Product__r.SerialNumber,
                Maintenance_Contract__r.Name,
                Maintenance_Contract__r.RecordType.Name,
                Management_Code__c,
                Contract_Start_Date__c,
                Contract_End_Date__c,
                VM_Maintenance_Contract__r.Name,
                VM_Maintenance_Contract__r.Management_Code__c,
                VM_Maintenance_Contract__r.startDateGurantee__c,
                VM_Maintenance_Contract__r.endDateGurantee__c,
                VM_Maintenance_Contract__r.RecordType.Name,
                ReRepairObject_result__c,
                Repair_Severity_Rank__c,
                Repair_Rank__c,
                InspectionResultFlag__c,
                DeliveryLogisticsMode__c,
                engineerSendDate__c,
                DeliveryLogisticsNo__c,
                ReturnLogisticsMode__c,
                ReturnLogisticsNo__c,
                ReturnLogisticsRemark__c,
                ReturnStage__c,
                ReturnOrderSendTime__c,
                ReturnLogisticsReceiveTime__c,
                On_Site_Repair_Order_Date__c,
                FSE_ApplyForRepair_Day__c,
                LogisticsSendTime__c,
                LogisticsReceiveTime__c,
                SAP_Transfer_day__c,
                Repair_Ordered_Date__c,
                Repair_Inspection_Date__c,
                Repair_Firstestimated_Date_formula__c,
                PlanQuotationTime__c,
                ActualQuotationStartTime__c,
                Repair_Quotation_date__c,
                Repair_Discount_approval_Date_formula__c,
                Discount_Price_formula__c,
                Agreed_Date__c,
                part_arrangement_complete__c,
                Repair_Start_Date__c,
                Planned_Repair_Completed_Date__c,
                Repair_Completed_Date__c,
                Repair_Final_Inspection_Date__c,
                Repair_Shipped_Date__c,
                OfficeLogisticsReceiveDate__c,
                Invoice_Date__c,
                Repair_Returned_To_HP_Date__c,
                Facility_Return_Receipt_Collection_reque__c,
                Receipt_received_date__c,
                Billing_Received_Date__c,
                Latest_Collect_Date_Priority__c,
                Received_Date__c,
                Facility_Return_Receipt_Collection_Date__c,
                BaddebtsDate__c,
                repair_cancel_date__c,
                RepairOrder_Complete_Day__c,
                if_Rental_Apply__c, On_site_repair__c,
                Offer_Rental_New__c,
                RcSorcDate__c,
                SorcAcceptDate__c,
                SorcOgzDate__c,
                RcOgzDate__c,
                Returns_Product_waySAP__c,
                DnNO__c,
                OgzAcceptDate__c,
                DeliveryLogisticsAnnotation__c,
                Department_Class__r.Management_Code__c,
                Repair_Ordered_DateTime__c,
                Repair_Inspection_DateTime__c,
                repair_cancel_dateTime__c,
                RcSorcDateTime__c,
                SorcAcceptDateTime__c,
                OgzAcceptDateTime__c,
                part_arrangement_complete_DateTime__c,
                Repair_Start_DateTime__c,
                Repair_Completed_DateTime__c,
                Repair_Final_Inspection_DateTime__c,
                Repair_Shipped_DateTime__c,
                Repair_Discount_approval_DateTime_form__c,
                Agreed_DateTime__c,
                //修理增加OTS运单号字段 thh 20220308 start
                OTSRepairOrder__c
                //修理增加OTS运单号字段 thh 20220308 end
                from Repair__c where id in: repairOrderIdList
            ];
        }
        String logstr = iflog.Log__c + ' ' + 'NumberOfRecord=' + repairList.size() + '\n';
        try {
            List < Id > repairIdList = new List < Id > ();
            for (Repair__c repair: repairList) {
                repairIdList.add(repair.Id);
            }
            // 故障描述
            Map < id, List < FaultDesc >> reasonMap = getFaultDescMap(repairOrderIdList);
            // 备品出借记录 查找备品出借一览明细的 产品型号
            Map < id, List < SparePartsLendingRecord >> rentalMap = getrentalMap(repairIdList);
 
            String downSDt = '';
            String downEDt = '';
            String upSDt = '';
            String upEDt = '';
 
 
            for (Repair__c repair: repairList) {
                RepairOrderInfo info = new RepairOrderInfo();
                info.repairOrderNo = repair.RepairSubOrder__r.RepairOrderNo__c;
                info.repairOrderNo2 = repair.RepairSubOrder__r.RepairSubOrderNo__c;
                info.repairNo = repair.Name; //修理单号
                info.hospitalCd = repair.Hospital__r.Management_Code__c; //医院编码
                info.SAPrepairNo = repair.SAP_Service_Repair_No__c; //SAP修理单号
                info.strategicDepartmenCd = repair.Department_Class__r.Management_Code__c; //战略科室编码
                info.departmentCd = repair.Account_Management_Code__c; //科室编码
                info.region = repair.Hospital__r.Salesdepartment_HP__c; //大区
                info.province = repair.State_Hospital__c; //省
                info.city = repair.Hospital__r.City_Master__r.Name; //--------------市
                info.repairApplicant = repair.Incharge_Staff__r.Employee_No__c; //---------修理委託人
                info.repairApplicantID = repair.Incharge_Staff__r.Employee_No__c; //修理委托人统一ID
                info.FSERepairOrderCreateDate = NFMUtil.formatDateTime2Str(repair.FSE_ApplyForRepair_time__c); // FSE申请修理时间
                info.SAPRepairOrderCreateDate = NFMUtil.formatDateTime2Str(repair.SAP_Transfer_time__c); //SAP修理申请时间
                info.equipmentModel = repair.Delivered_Product__r.Product_Name__c; //设备型号
                info.equipmentCd = repair.Delivered_Product__r.SerialNumber; //----------机身编码
                info.On_site_repair = repair.On_site_repair__c; //================服务方式=============待定
                info.ContractName = repair.Maintenance_Contract__r.Name; //维修合同名称
                info.ContractData = repair.Maintenance_Contract__r.RecordType.Name; //维修合同记录类型
                info.ContractNo = repair.Management_Code__c; //维修合同编码
                info.ContractStartDate = NFMUtil.formatDate2StrDateTime(repair.Contract_Start_Date__c); //维修合同开始日期
                info.ContractEndDate = NFMUtil.formatDate2StrDateTime(repair.Contract_End_Date__c); //维修合同结束日期
                info.MultiYearContractName = repair.VM_Maintenance_Contract__r.Name; //多年保合同名称
                info.MultiYearContractNo = repair.VM_Maintenance_Contract__r.Management_Code__c; //-------多年保合同编号
                info.MultiYearContractStartDate = NFMUtil.formatDate2StrDateTime(repair.VM_Maintenance_Contract__r.startDateGurantee__c); //多年保合同开始日
                info.MultiYearContractEndDate = NFMUtil.formatDate2StrDateTime(repair.VM_Maintenance_Contract__r.endDateGurantee__c); //多年保合同结束日
                info.MultiYearContractData = repair.VM_Maintenance_Contract__r.RecordType.Name; //多年保记录类型
                info.isRepairWarrantyObj = repair.ReRepairObject_result__c; //再修理保修对象
                info.RepairType = repair.Repair_Severity_Rank__c; //修理区分----------
                info.QuotationGread = repair.Repair_Rank__c; //报价等级
                info.detectionResult = repair.InspectionResultFlag__c; //检测结果
                info.FaultDesc = reasonMap.get(repair.id); //故障描述List
                ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                info.deliveryLogisticsMode = repair.DeliveryLogisticsMode__c; //送修物流方式======自己写字段
                //update                wangweipeng     2022/02/16                start
                //info.engineerSendDate = NFMUtil.formatDate2StrDateTime(repair.engineerSendDate__c); // 工程师修理品寄送日
                info.engineerSendDate = NFMUtil.formatDateTime2Str(repair.engineerSendDate__c); // 工程师修理品寄送日
                //update                wangweipeng     2022/02/16                end
                info.deliveryLogisticsNo = repair.DeliveryLogisticsNo__c; //送修物流单号======自己写字段
                info.returnLogisticsMode = repair.ReturnLogisticsMode__c; //返送物流方式======自己写字段
                info.DeliveryLogisticsAnnotation = repair.DeliveryLogisticsAnnotation__c; //送修物流信息备注
                info.returnLogisticsNo = repair.ReturnLogisticsNo__c; //返送物流单号======自己写字段
                info.returnLogisticsRemark = repair.ReturnLogisticsRemark__c; //返送物流备注信息======自己写字段
                info.returnStage = repair.ReturnStage__c; //维修品返送所处阶段======自己写字段
                info.returnLogisticsSendTime = NFMUtil.formatDateTime2Str(repair.ReturnOrderSendTime__c); //返送物流发送时间======自己写字段
                info.returnLogisticsReceiveTime = NFMUtil.formatDateTime2Str(repair.ReturnLogisticsReceiveTime__c); //返送物流签收时间======自己写字段
                info.repairproductsRevDate = NFMUtil.formatDate2StrDateTime(repair.On_Site_Repair_Order_Date__c); //故障品接收日
                //update                wangweipeng     2022/02/16                start
                //info.FSErepairApplyDate = NFMUtil.formatDate2StrDateTime(repair.FSE_ApplyForRepair_Day__c); //FSE修理申请日======自己写字段
                info.FSErepairApplyDate = NFMUtil.formatDateTime2Str(repair.FSE_ApplyForRepair_time__c); // FSE修理申请时间
                //update                wangweipeng     2022/02/16                end
                info.logisticsSendDate = NFMUtil.formatDateTime2Str(repair.LogisticsSendTime__c); //物流发送日======自己写字段
                info.logisticsReceiveDate = NFMUtil.formatDateTime2Str(repair.LogisticsReceiveTime__c); //物流接收日======自己写字段
                //update                wangweipeng     2022/02/16                start
                //info.SAPrepairApplyDate = NFMUtil.formatDate2StrDateTime(repair.SAP_Transfer_day__c); //SAP修理申请日======自己写字段
                info.SAPrepairApplyDate = NFMUtil.formatDateTime2Str(repair.SAP_Transfer_time__c); // SAP修理申请时间
                //info.RCacceptanceDate = NFMUtil.formatDate2StrDateTime(repair.Repair_Ordered_Date__c); //修理品RC受理日
                info.RCacceptanceDate = NFMUtil.formatDateTime2Str(repair.Repair_Ordered_DateTime__c); //4.修理品RC受理日(小程序)
                //info.inspectionDate = NFMUtil.formatDate2StrDateTime(repair.Repair_Inspection_Date__c); //修理检测日
                info.inspectionDate = NFMUtil.formatDateTime2Str(repair.Repair_Inspection_DateTime__c); //5.修理检测日(小程序)
                info.FirstQuotationDate = NFMUtil.formatDate2StrDateNewTime(repair.Repair_Firstestimated_Date_formula__c); //初次报价日
                //info.priceApprovalDate = NFMUtil.formatDate2StrDateTime(repair.Repair_Discount_approval_Date_formula__c); //减价申请批准日
                info.priceApprovalDate = NFMUtil.formatDateTime2Str(repair.Repair_Discount_approval_DateTime_form__c); //减价申请批准日(小程序)
                info.quotationDate = NFMUtil.formatDate2StrDateNewTime(repair.Repair_Quotation_date__c); //报价日
                //info.cancelRepairDate = NFMUtil.formatDate2StrDateTime(repair.repair_cancel_date__c); //修理取消日
                info.cancelRepairDate = NFMUtil.formatDateTime2Str(repair.repair_cancel_dateTime__c); //修理取消日(小程序)
                //info.userAgreeDAte = NFMUtil.formatDate2StrDateTime(repair.Agreed_Date__c); //用户同意日
                info.userAgreeDAte = NFMUtil.formatDateTime2Str(repair.Agreed_DateTime__c); //7.用户同意日(小程序)
                //info.partsCompleteDate = NFMUtil.formatDate2StrDateTime(repair.part_arrangement_complete__c); //零件齐备完毕日
                info.partsCompleteDate = NFMUtil.formatDateTime2Str(repair.part_arrangement_complete_DateTime__c); //零件齐备完毕日
                //info.repairStartDate = NFMUtil.formatDate2StrDateTime(repair.Repair_Start_Date__c); //修理开始日
                info.repairStartDate = NFMUtil.formatDateTime2Str(repair.Repair_Start_DateTime__c); //8.修理开始日(小程序)
                //info.repairCompleteDate = NFMUtil.formatDate2StrDateTime(repair.Repair_Completed_Date__c); //修理完成日
                info.repairCompleteDate = NFMUtil.formatDateTime2Str(repair.Repair_Completed_DateTime__c); //9.修理完成日(小程序)
                //info.finalTestDate = NFMUtil.formatDate2StrDateTime(repair.Repair_Final_Inspection_Date__c); //最终检测日
                info.finalTestDate = NFMUtil.formatDateTime2Str(repair.Repair_Final_Inspection_DateTime__c); //10.最终检测日(小程序)
                //update                wangweipeng     2022/02/16                end
                info.planQuotationDate = NFMUtil.formatDateTime2Str(repair.PlanQuotationTime__c); //计划报价日======自己写字段
                info.ActualQuotationDate = NFMUtil.formatDateTime2Str(repair.ActualQuotationStartTime__c); //实际报价日======自己写字段
                info.finalQuotationPrice = repair.Discount_Price_formula__c; //最终报价金额======自己写字段
                info.repairCompleteExpectedDate = NFMUtil.formatDate2StrDateTime(repair.Planned_Repair_Completed_Date__c); //修理完成预计日
 
                info.RCreturnDate = null; //RC修理品返送日
                info.ReturnsProductWay = null; //返品方式  
                if (repair.Repair_Shipped_Date__c != null && String.isNotBlank(repair.Returns_Product_waySAP__c)) {
                    //info.RCreturnDate = NFMUtil.formatDate2StrDateTime(repair.Repair_Shipped_Date__c); //RC修理品返送日
                    info.RCreturnDate = NFMUtil.formatDateTime2Str(repair.Repair_Shipped_DateTime__c); //RC修理品返送日  wangweipeng     2022/02/16
                    info.ReturnsProductWay = repair.Returns_Product_waySAP__c; //返品方式    
                }
 
                info.officeLogisticsReceiveDate = NFMUtil.formatDateTime2Str(repair.OfficeLogisticsReceiveDate__c); //办事处物流接收日======自己写字段-SAP提供物流信息
                info.invoiceDate = NFMUtil.formatDate2StrDateTime(repair.Invoice_Date__c); //开发票日
                info.userReturnDate = NFMUtil.formatDate2StrDateTime(repair.Repair_Returned_To_HP_Date__c); //修理品用户返送日
                info.acceptanceFormSendDate = NFMUtil.formatDate2StrDateTime(repair.Facility_Return_Receipt_Collection_reque__c); //验收单现场寄送日
                info.acceptanceFormReceivedDate = NFMUtil.formatDate2StrDateTime(repair.Receipt_received_date__c); //验收单收到日
                info.invoiceReceiveDate = NFMUtil.formatDate2StrDateTime(repair.Billing_Received_Date__c); //发票接收日
                info.latestPayDate = NFMUtil.formatDate2StrDateTime(repair.Latest_Collect_Date_Priority__c); //最新回款日
                info.payCompleteDate = NFMUtil.formatDate2StrDateTime(repair.Received_Date__c); //回款完毕日
                info.incomeReckoninDate = NFMUtil.formatDate2StrDateTime(repair.Facility_Return_Receipt_Collection_Date__c); //收入计入日
                info.abandonPayDate = NFMUtil.formatDate2StrDateTime(repair.BaddebtsDate__c); //放弃回款日
                info.repairOrderCompleteDate = NFMUtil.formatDate2StrDateTime(repair.RepairOrder_Complete_Day__c); //修理单完成日
                info.applySpareEquip = repair.if_Rental_Apply__c; //是否申请备品======自己写字段
                info.supplySpareEquip = repair.Offer_Rental_New__c + ''; //是否提供备品
                info.SparePartsLendingRecord = rentalMap.get(repair.Id);
 
                //update        wangweipeng         2022/02/16           start
                //info.RcSorcDate = NFMUtil.formatDate2StrDateTime(repair.RcSorcDate__c);//RC转SORC日
                info.RcSorcDate = NFMUtil.formatDateTime2Str(repair.RcSorcDateTime__c);//RC转SORC日(小程序)
                //info.SorcAcceptDate = NFMUtil.formatDate2StrDateTime(repair.SorcAcceptDate__c);//SORC受理日
                info.SorcAcceptDate = NFMUtil.formatDateTime2Str(repair.SorcAcceptDateTime__c);//SORC受理日(小程序)
                //info.OgzAcceptDate = NFMUtil.formatDate2StrDateTime(repair.OgzAcceptDate__c);//OGZ受理日
                info.OgzAcceptDate = NFMUtil.formatDateTime2Str(repair.OgzAcceptDateTime__c);//OGZ受理日(小程序)
                //update        wangweipeng         2022/02/16           end
 
                // info.SorcOgzDate = NFMUtil.formatDate2StrDateTime(repair.SorcOgzDate__c);RcOgzDate__c
 
                //update   zhangyuheng    2022/03/07
                info.SorcOgzDate = NFMUtil.formatDate2StrDateTime(repair.RcOgzDate__c);
 
                info.cus_dn = repair.DnNO__c;
                //修理增加OTS运单号字段 thh 20220308 start
                info.OTSRepairOrder = repair.OTSRepairOrder__c;
                //修理增加OTS运单号字段 thh 20220308 end
 
                //报价日、初次报价日、RC修理品RC受理日(小程序)时间判断   zyh  20220315   start
                downSDt = DownStartDt();
                downEDt = DownEndDt();
                upSDt = UpStartDt();
                upEDt = UpEndDt();
                // 2022-05-07  zyh     update  start
                if (String.isNotBlank(info.FirstQuotationDate)) {
                    info.FirstQuotationDate = info.FirstQuotationDate.deleteWhitespace();
                }
                if (String.isNotBlank(info.quotationDate)) {
                    info.quotationDate = info.quotationDate.deleteWhitespace();
                }
                // 2022-05-07  zyh     update  end
                //定义下班时间
                if (String.valueOf(info.FirstQuotationDate) >= String.valueOf(downSDt) && String.valueOf(info.FirstQuotationDate) <= String.valueOf(downEDt)) {
                    info.FirstQuotationDate = DownDt();//初次报价日
                }
                if (String.valueOf(info.RCacceptanceDate) >= String.valueOf(downSDt) && String.valueOf(info.RCacceptanceDate) <= String.valueOf(downEDt)) {
                    info.RCacceptanceDate = DownDt();//4.修理品RC受理日
                }
                if (String.valueOf(info.quotationDate) >= String.valueOf(downSDt) && String.valueOf(info.quotationDate) <= String.valueOf(downEDt)) {
                    info.quotationDate = DownDt();//报价日
                }
                if (String.valueOf(info.FSErepairApplyDate) >= String.valueOf(downSDt) && String.valueOf(info.FSErepairApplyDate) <= String.valueOf(downEDt)) {
                    info.FSErepairApplyDate = DownDt();//FSE修理申请时间  2022-05-06--zyh--add
                }
                if (String.valueOf(info.RCreturnDate) >= String.valueOf(downSDt) && String.valueOf(info.RCreturnDate) <= String.valueOf(downEDt)) {
                    info.RCreturnDate = DownDt();//RC修理品返送日  2022-05-06--zyh--add
                }
                if (String.valueOf(info.finalTestDate) >= String.valueOf(downSDt) && String.valueOf(info.finalTestDate) <= String.valueOf(downEDt)) {
                    info.finalTestDate = DownDt();//10.最终检测日(小程序)  2022-05-06--zyh--add
                }
                if (String.valueOf(info.userAgreeDAte) >= String.valueOf(downSDt) && String.valueOf(info.userAgreeDAte) <= String.valueOf(downEDt)) {
                    info.userAgreeDAte = DownDt();//7.用户同意日(小程序)  2022-05-06--zyh--add
                }
                if (String.valueOf(info.engineerSendDate) >= String.valueOf(downSDt) && String.valueOf(info.engineerSendDate) <= String.valueOf(downEDt)) {
                    info.engineerSendDate = DownDt();//工程师修理品寄送日  2022-05-06--zyh--add
                }
                //定义上班时间
                if (String.valueOf(info.FirstQuotationDate) >= String.valueOf(upSDt) && String.valueOf(info.FirstQuotationDate) <= String.valueOf(upEDt)) {
                    info.FirstQuotationDate = UpDt();//初次报价日
                }
                if (String.valueOf(info.RCacceptanceDate) >= String.valueOf(upSDt) && String.valueOf(info.RCacceptanceDate) <= String.valueOf(upEDt)) {
                    info.RCacceptanceDate = UpDt();//4.修理品RC受理日
                }
                if (String.valueOf(info.quotationDate) >= String.valueOf(upSDt) && String.valueOf(info.quotationDate) <= String.valueOf(upEDt)) {
                    info.quotationDate = UpDt();//报价日
                }
                if (String.valueOf(info.FSErepairApplyDate) >= String.valueOf(upSDt) && String.valueOf(info.FSErepairApplyDate) <= String.valueOf(upEDt)) {
                    info.FSErepairApplyDate = UpDt();//FSE修理申请时间  2022-05-06--zyh--add
                }
                if (String.valueOf(info.RCreturnDate) >= String.valueOf(upSDt) && String.valueOf(info.RCreturnDate) <= String.valueOf(upEDt)) {
                    info.RCreturnDate = UpDt();//RC修理品返送日  2022-05-06--zyh--add
                }
                if (String.valueOf(info.finalTestDate) >= String.valueOf(upSDt) && String.valueOf(info.finalTestDate) <= String.valueOf(upEDt)) {
                    info.finalTestDate = UpDt();//10.最终检测日(小程序)  2022-05-06--zyh--add
                }
                if (String.valueOf(info.userAgreeDAte) >= String.valueOf(upSDt) && String.valueOf(info.userAgreeDAte) <= String.valueOf(upEDt)) {
                    info.userAgreeDAte = UpDt();//7.用户同意日(小程序)  2022-05-06--zyh--add
                }
                if (String.valueOf(info.engineerSendDate) >= String.valueOf(upSDt) && String.valueOf(info.engineerSendDate) <= String.valueOf(upEDt)) {
                    info.engineerSendDate = UpDt();//工程师修理品寄送日  2022-05-06--zyh--add
                }
                //报价日、初次报价日、RC修理品RC受理日(小程序)时间判断   zyh  20220315   end
                repairs.add(info);
                System.debug('repairs1:' + repairs);
            }
            logstr += '\nend';
            if (repairs.size() > 0) {
                // 2022-05-05      zyh     update      start
                for (RepairOrderInfo roi : repairs ) {
                    repairs1.add(roi);
                    rowData = NFMUtil.makeRowData(iflog, LOG_TYPE, repairs1);
                    // 2022-05-07  zyh     update  start
                    if (String.isBlank(rowData.MessageGroupNumber__c)) {
                        rowData.MessageGroupNumber__c = nowStr;
                    }
                    // 2022-05-07  zyh     update  end
                    execute1(rowData, iflog);
                    // rowData = NFMUtil.makeRowData(iflog, LOG_TYPE, repairs);
                    // execute(rowData, iflog);
                    repairs1 = new List < RepairOrderInfo > ();
                }
                upsert logList;
                upsert rowList;
                delete logMap.values();
                // 2022-05-05      zyh     update      end
                // upsert rowData;
            }
        } catch (Exception e) {
            // 发生错误时
            System.debug(Logginglevel.ERROR, LOG_TYPE + iflog.Name + ':' + e.getMessage());
            System.debug(Logginglevel.ERROR, LOG_TYPE + iflog.Name + ':' + e.getStackTraceString());
            logstr += e.getMessage();
            iflog.ErrorLog__c += e.getMessage() + '\n';
            iflog.ErrorLog__c += e.getStackTraceString() + '\n';
            iflog.Log__c = iflog.Log__c + logstr;
            upsert iflog;
        }
        if (rowData != null) {
            upsert rowData;
        }
 
    }
    /**
     * 接口发送失败 根据BatchLogId进行手动发送
     * @Author   XHL
     * @DateTime 2021-07-22
     * @param    rowDataId  [BatchLogId]
     */
    public static void ManualExecute(String rowDataId) {
        List < BatchIF_Log__c > row = [select id, name, MessageGroupNumber__c, retry_cnt__c,
            RowDataFlg__c, ErrorLog__c, Type__c,
            Log__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c,
            Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c
            from BatchIF_Log__c
            where id =: rowDataId
        ];
        if (row.size() > 0) execute(row[0], null);
    }
    /**
     * 逻辑正常执行发送
     * @Author   XHL
     * @DateTime 2021-07-22
     * @param    rowDataSFDC [BatchLogId]
     * @param    iflog       [执行情况记录]
     */
    public static void execute(BatchIF_Log__c rowDataSFDC, BatchIF_Log__c iflog) {
        Integer batch_retry_max_cnt = Integer.valueOf(System.Label.batch_retry_max_cnt);
 
        String logstr = rowDataSFDC.MessageGroupNumber__c + ' start\n';
        if (iflog == null) {
            iflog = new BatchIF_Log__c();
            iflog.Type__c = LOG_TYPE;
            iflog.MessageGroupNumber__c = rowDataSFDC.MessageGroupNumber__c;
            iflog.Log__c = logstr;
            iflog.ErrorLog__c = '';
 
        } else {
            iflog.Type__c = LOG_TYPE;
            iflog.MessageGroupNumber__c = rowDataSFDC.MessageGroupNumber__c;
            logstr = iflog.Log__c;
        }
 
        try {
            String data = NFMUtil.getRowDataStr(rowDataSFDC);
            String status = NFMUtil.sendToAWS(data, API);
            System.debug('NFM603Log--status->' + status);
 
            if ('OK'.equals(status)) {
                logstr += status + '\n';
                rowDataSFDC.retry_cnt__c = 0;
            } else {
                rowDataSFDC = NFMUtil.LogAutoSend(rowDataSFDC, null, status);
            }
 
        } catch (Exception ex) {
            // TODO IOException
            // 错误发生时
            logstr += ex.getMessage();
            iflog.ErrorLog__c += ex.getMessage() + '\n';
            iflog.ErrorLog__c += ex.getStackTraceString() + '\n';
            if(!Test.isRunningTest()){
                rowDataSFDC = NFMUtil.LogAutoSend(rowDataSFDC, ex, null);
            }
        }
        iflog.Log__c = logstr;
        upsert iflog;
        upsert rowDataSFDC;
        // logList.add(iflog);
        // rowList.add(rowDataSFDC);
 
    }
    // 2022-05-05      zyh     update      start
    public static void execute1(BatchIF_Log__c rowDataSFDC, BatchIF_Log__c iflog) {
        Integer batch_retry_max_cnt = Integer.valueOf(System.Label.batch_retry_max_cnt);
 
        String logstr = rowDataSFDC.MessageGroupNumber__c + ' start\n';
        if (iflog == null) {
            iflog = new BatchIF_Log__c();
            iflog.Type__c = LOG_TYPE;
            iflog.MessageGroupNumber__c = rowDataSFDC.MessageGroupNumber__c;
            iflog.Log__c = logstr;
            iflog.ErrorLog__c = '';
 
        } else {
            // iflog.Type__c = LOG_TYPE;
            // iflog.MessageGroupNumber__c = rowDataSFDC.MessageGroupNumber__c;
            // logstr = iflog.Log__c;
            logMap.put(iflog.Id, iflog);
            iflog = new BatchIF_Log__c();
            iflog.Type__c = LOG_TYPE;
            iflog.MessageGroupNumber__c = rowDataSFDC.MessageGroupNumber__c;
            iflog.Log__c = logstr;
            iflog.ErrorLog__c = '';
        }
 
        try {
            String data = NFMUtil.getRowDataStr(rowDataSFDC);
            String status = NFMUtil.sendToAWS(data, API);
            System.debug('NFM603Log--status->' + status);
 
            if ('OK'.equals(status)) {
                logstr += status + '\n';
                rowDataSFDC.retry_cnt__c = 0;
            } else {
                rowDataSFDC = NFMUtil.LogAutoSend(rowDataSFDC, null, status);
            }
 
        } catch (Exception ex) {
            // TODO IOException
            // 错误发生时
            logstr += ex.getMessage();
            iflog.ErrorLog__c += ex.getMessage() + '\n';
            iflog.ErrorLog__c += ex.getStackTraceString() + '\n';
            if(!Test.isRunningTest()){
                rowDataSFDC = NFMUtil.LogAutoSend(rowDataSFDC, ex, null);
            }
        }
        iflog.Log__c = logstr;
        // upsert iflog;
        // upsert rowDataSFDC;
        logList.add(iflog);
        rowList.add(rowDataSFDC);
 
    }
 
    // 2022-05-05      zyh     update      end
    // 故障描述
    private static Map < id, List < FaultDesc >> getFaultDescMap(List < String > repairOrderIdList) {
        List < Repair_reason__c > reasonList =
            [SELECT Id, DescriptionName__c, LocationName__c, ActivityDescription__c, Repair__c
                FROM Repair_reason__c
                WHERE Repair__c
                IN: repairOrderIdList
            ];
        Map < id, List < FaultDesc >> reasonMap = new Map < id, List < FaultDesc >> ();
        for (Repair_reason__c reason: reasonList) {
            List < FaultDesc > temp = reasonMap.get(reason.Repair__c);
            if (temp == null) {
                temp = new List < FaultDesc > ();
            }
            FaultDesc faulDesc = new FaultDesc();
            faulDesc.repairPosition = reason.LocationName__c; //修理部位
            faulDesc.faultDescription = reason.DescriptionName__c; //故障描述
            faulDesc.repairContentDesc = reason.ActivityDescription__c; //修理内容描述
            temp.add(faulDesc);
            reasonMap.put(reason.Repair__c, temp);
        }
 
        return reasonMap;
 
 
    }
 
    // 备品出借记录
    private static Map < id, List < SparePartsLendingRecord >> getrentalMap(List < Id > repairIdList) {
        List < Rental_Apply_Equipment_Set_Detail__c > equipList = [
            SELECT Name, Repair__c, Bollow_Date__c, Fixture_Model_No__c, Fixture_Model_No_F__c, Cancel_Select__c,
            Rental_Apply_Equipment_Set__r.Rental_Apply__r.Name,
            Rental_Apply_Equipment_Set__r.Bollow_Date__c,
            Rental_Apply_Equipment_Set__r.Rental_Apply__r.Repair__c
            FROM Rental_Apply_Equipment_Set_Detail__c WHERE Cancel_Select__c = false AND Rental_Apply_Equipment_Set__r.Rental_Apply__r.Repair__c IN: repairIdList
        ];
        Map < id, List < SparePartsLendingRecord >> rentalMap = new Map < id, List < SparePartsLendingRecord >> ();
 
        for (Rental_Apply_Equipment_Set_Detail__c detail: equipList) {
            String repairId = detail.Rental_Apply_Equipment_Set__r.Rental_Apply__r.Repair__c;
            List < SparePartsLendingRecord > renList = rentalMap.get(repairId);
            if (renList == null) {
                renList = new List < SparePartsLendingRecord > ();
            }
            SparePartsLendingRecord splr = new SparePartsLendingRecord();
            splr.spareEquipapplicationNo = detail.Rental_Apply_Equipment_Set__r.Rental_Apply__r.Name; //备品申请编号
            splr.spareEquipLendingDate = NFMUtil.formatDate2StrDateTime(detail.Rental_Apply_Equipment_Set__r.Bollow_Date__c); //备品出借日期
            splr.spareEquipMode = detail.Fixture_Model_No_F__c;
            renList.add(splr);
            rentalMap.put(repairId, renList);
        }
        return rentalMap;
    }
 
    public static Set < Id > NFM603_Ids = new Set < Id > ();
    // public static Map<Id,Id> rprIdMap = new Map<Id,Id>();
    
    public static void NFM603Trigger(List < Repair__c > newList, Map < Id, Repair__c > newMap, List < Repair__c > oldList, Map < Id, Repair__c > oldMap) {
        List < String > rprIds = new List < String > ();
        Map < Id, Id > rprIdMap = new Map < Id, Id > ();
        if (Trigger.isAfter) {
            if (Trigger.isInsert) {
                for (Repair__c rpr: newList) {
                    if (rpr.status__c == '1.受理完毕') {
                        if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
                            if (String.isNotBlank(rpr.RepairSubOrder__c)) {
                                NFM603Controller.NFM603_Ids.add(rpr.Id);
                                rprIdMap.put(rpr.Id, rpr.Id);
                            }
 
                        }
                    }
                }
            }
 
 
            if (Trigger.isUpdate) {
                for (Repair__c rpr: newList) {
                    Repair__c oldrpr = oldMap.get(rpr.Id);
                    // 修理有报修子单号,并且 待发送AWS为false 发送给AWS
                    if (String.isNotBlank(rpr.RepairSubOrder__c) && !rpr.AwaitToSendAWS__c) {
                        if (((rpr.status__c == '0.申请完毕' || rpr.status__c == '1.受理完毕') && (oldrpr.SAP_Transfer_time__c == null && rpr.SAP_Transfer_time__c != null)) || 
                            (rpr.Address_type__c == 'X' && (rpr.Address_Type_Index__c != oldrpr.Address_Type_Index__c)) || 
                            //  2022/4/6    zhangyuheng update start
                            (rpr.OTSRepairOrder__c != oldrpr.OTSRepairOrder__c) || // OTS订单号有值,发送AWS
                            //  2022/4/6    zhangyuheng update end
                            //  2022/4/7    zhangyuheng update start
                            (rpr.DeliveryLogisticsNo__c != oldrpr.DeliveryLogisticsNo__c) || // 送修物流单号有值,发送AWS
                            // ((rpr.Discount_Price_formula__c != oldrpr.Discount_Price_formula__c) && rpr.Repair_Firstestimated_Date_formula__c != null) || // 报价金额发生改变且初次报价日有值,发送AWS
                            ((rpr.Returns_Product_waySAP__c != oldrpr.Returns_Product_waySAP__c) && rpr.Repair_Shipped_DateTime__c != null) || // 送修方式发生改变且寄送日有值,发送AWS
                            //  2022/4/7    zhangyuheng update end
                            //  2022/4/18    zhangyuheng update start
                            (rpr.FSE_ApplyForRepair_time__c != oldrpr.FSE_ApplyForRepair_time__c) ||                   // FSE申请修理日发生改变,发送AWS
                            (rpr.Repair_Ordered_DateTime__c != oldrpr.Repair_Ordered_DateTime__c) ||                   // 4.修理品RC受理日(小程序)发生改变,发送AWS
                            (rpr.Repair_Firstestimated_Date__c != oldrpr.Repair_Firstestimated_Date__c) ||             // 初次报价日(不用)发生改变,发送AWS
                            (rpr.Repair_Shipped_DateTime__c != oldrpr.Repair_Shipped_DateTime__c) ||                   // 11.RC修理品返送日(小程序)发生改变,发送AWS
                            (rpr.Repair_Final_Inspection_DateTime__c != oldrpr.Repair_Final_Inspection_DateTime__c) || // 10.最终检测日(小程序)发生改变,发送AWS
                            (rpr.Agreed_DateTime__c != oldrpr.Agreed_DateTime__c) ||                                   //7.用户同意日(小程序)发生改变,发送AWS
                            (rpr.Agreed_Date__c != oldrpr.Agreed_Date__c) ||                                           // 7.用户同意日发生改变,发送AWS
                            (rpr.engineerSendDate__c != oldrpr.engineerSendDate__c)                                    //修理品寄送日发生改变,发送AWS
                            //  2022/4/18    zhangyuheng update start
                            ) {
 
                            if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
                                NFM603Controller.NFM603_Ids.add(rpr.Id);
                                rprIdMap.put(rpr.Id, rpr.Id);
                            }
                        }
                        //  2022/4/19    zhangyuheng update start
                        // 如果同期中的修理报价(Repair_Quotation_Id__c)为空,判断初次报价日和报价金额
                        if (rpr.Repair_Quotation_Id__c != oldrpr.Repair_Quotation_Id__c) {
                            if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
                                NFM603Controller.NFM603_Ids.add(rpr.Id);
                                rprIdMap.put(rpr.Id, rpr.Id);
                            }
                        }
                        if (rpr.Repair_Quotation_Id__c == null) {
                            // 如果初次报价日(不用)或折扣后金额(不用)发生改变,发送AWS
                            if (rpr.Discount_Price__c != oldrpr.Discount_Price__c || rpr.Repair_Estimated_Date__c != oldrpr.Repair_Estimated_Date__c) {
                                if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
                                    NFM603Controller.NFM603_Ids.add(rpr.Id);
                                    rprIdMap.put(rpr.Id, rpr.Id);
                                }
                            }
                        }
                        // 如果同期中的修理报价(Repair_Quotation_Id__c)不为空,在RepairQuoteTrigger.ChangeRepair进行判断触发
                        //  2022/4/19    zhangyuheng update end
                        
                        //  2022/4/6    zhangyuheng update start
                        //OTS订单号有值,发送AWS
                        // if ((oldrpr.OTSRepairOrder__c == null && String.isNotBlank(rpr.OTSRepairOrder__c)) || rpr.OTSRepairOrder__c != oldrpr.OTSRepairOrder__c) {
                        //     if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
                        //         NFM603Controller.NFM603_Ids.add(rpr.Id);
                        //         rprIdMap.put(rpr.Id, rpr.Id);
                        //     }
                        // }
                        //  2022/4/6    zhangyuheng update end
                        //  2022/4/7    zhangyuheng update start
                        //送修物流单号有值,发送AWS
                        // if ((oldrpr.DeliveryLogisticsNo__c == null && String.isNotBlank(rpr.DeliveryLogisticsNo__c))  || rpr.DeliveryLogisticsNo__c != oldrpr.DeliveryLogisticsNo__c) {
                        //     if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
                        //         NFM603Controller.NFM603_Ids.add(rpr.Id);
                        //         rprIdMap.put(rpr.Id, rpr.Id);
                        //     }
                        // }
                        //报价金额发生改变且初次报价日有值,发送AWS
                        // if ((rpr.Discount_Price_formula__c != oldrpr.Discount_Price_formula__c) && rpr.Repair_Firstestimated_Date_formula__c != null) {
                        //     if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
                        //         NFM603Controller.NFM603_Ids.add(rpr.Id);
                        //         rprIdMap.put(rpr.Id, rpr.Id);
                        //     }
                        // }
                        // if ((rpr.Returns_Product_waySAP__c != oldrpr.Returns_Product_waySAP__c) && rpr.Repair_Shipped_DateTime__c != null) {
                        //     if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
                        //         NFM603Controller.NFM603_Ids.add(rpr.Id);
                        //         rprIdMap.put(rpr.Id, rpr.Id);
                        //     }
                        // }
                        //  2022/4/7    zhangyuheng update end
                        //  2022/4/18    zhangyuheng update start
                        // FSE申请修理日发生改变,发送AWS
                        // if (rpr.FSE_ApplyForRepair_time__c != oldrpr.FSE_ApplyForRepair_time__c) {
                        //     if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
                        //         NFM603Controller.NFM603_Ids.add(rpr.Id);
                        //         rprIdMap.put(rpr.Id, rpr.Id);
                        //     }
                        // }
                        // 4.修理品RC受理日(小程序)发生改变,发送AWS
                        // if (rpr.Repair_Ordered_DateTime__c != oldrpr.Repair_Ordered_DateTime__c) {
                        //     if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
                        //         NFM603Controller.NFM603_Ids.add(rpr.Id);
                        //         rprIdMap.put(rpr.Id, rpr.Id);
                        //     }
                        // }
                        // 初次报价日(不用)发生改变,发送AWS
                        // if (rpr.Repair_Firstestimated_Date__c != oldrpr.Repair_Firstestimated_Date__c) {
                        //     if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
                        //         NFM603Controller.NFM603_Ids.add(rpr.Id);
                        //         rprIdMap.put(rpr.Id, rpr.Id);
                        //     }
                        // }
                        // 11.RC修理品返送日(小程序)发生改变,发送AWS
                        // if (rpr.Repair_Shipped_DateTime__c != oldrpr.Repair_Shipped_DateTime__c) {
                        //     if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
                        //         NFM603Controller.NFM603_Ids.add(rpr.Id);
                        //         rprIdMap.put(rpr.Id, rpr.Id);
                        //     }
                        // }
                        // 10.最终检测日(小程序)发生改变,发送AWS
                        // if (rpr.Repair_Final_Inspection_DateTime__c != oldrpr.Repair_Final_Inspection_DateTime__c) {
                        //     if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
                        //         NFM603Controller.NFM603_Ids.add(rpr.Id);
                        //         rprIdMap.put(rpr.Id, rpr.Id);
                        //     }
                        // }
                        //  2022/4/18    zhangyuheng update end
                        // 测试环境测试用,上线前请注掉
                        // if (rpr.Repair_Firstestimated_Date__c != oldrpr.Repair_Firstestimated_Date__c) {
                        //     if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
                        //         NFM603Controller.NFM603_Ids.add(rpr.Id);
                        //         // rprIds.add(rpr.Id);
                        //         rprIdMap.put(rpr.Id, rpr.Id);
                        //     }
                        // }
                        // if (rpr.Repair_Shipped_Date__c != oldrpr.Repair_Shipped_Date__c) {
                        //     if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
                        //         NFM603Controller.NFM603_Ids.add(rpr.Id);
                        //         rprIdMap.put(rpr.Id, rpr.Id);
                        //     }
                        // }
                        // 测试环境测试用,上线前请注掉
                    }
 
                }
            }
 
            rprIds = rprIdMap.values();
 
            if (rprIds.size() > 0) {
                BatchIF_Log__c iflog = new BatchIF_Log__c();
                iflog.Type__c = LOG_TYPE;
                iflog.Log__c = 'callout start\n';
                insert iflog;
                // 2022-04-29     zyh      update     start
                if(UserInfo.getUserId().equals(System.Label.interfaceUserID)){
                    NFM603Controller.executefuture(iflog, rprIds);
                }else{
                    NFM603Controller.callout(iflog.Id, rprIds);
                }
                // 2022-04-29     zyh      update     end
            }
        } else {
            if (Trigger.isUpdate) {
                for (Repair__c rpr: newList) {
                    Repair__c oldrpr = oldMap.get(rpr.Id);
                    // 修理的报修子单字段有值,修理单状态编号变更 需 发送AWS
                    if (String.isNotBlank(rpr.RepairSubOrder__c) && rpr.RepairOrderStatusCode__c != oldrpr.RepairOrderStatusCode__c) {
                        rpr.AwaitToSendAWS__c = true;
                    }
                }
            }
        }
    }
 
    //报价日、初次报价日、RC修理品RC受理日(小程序)时间方法   zyh  20220315   start
    //下班开始时间
    public static String DownStartDt(){
        String timenow = Datetime.now().format('yyyyMMddHHmmss');
        String dt = NFMUtil.formatDate2Str(Date.today());
        String rtn = null;
        if (dt == null) {
            return rtn;
        }
        rtn = String.valueOf(dt);
        rtn = rtn.replaceAll('-', '');
        if (rtn >= '40001231') {
            rtn = '99991231';
        } else if (rtn < '19000101') {
            rtn = '19000101';
        }
        return rtn + '173001';
    }
    //下班结束时间
    public static String DownEndDt(){
        String dt = NFMUtil.formatDate2Str(Date.today());
        String rtn = null;
        if (dt == null) {
            return rtn;
        }
        rtn = String.valueOf(dt);
        rtn = rtn.replaceAll('-', '');
        if (rtn >= '40001231') {
            rtn = '99991231';
        } else if (rtn < '19000101') {
            rtn = '19000101';
        }
        return rtn + '235959';
    }
    //上班开始时间
    public static String UpStartDt(){
        String dt = NFMUtil.formatDate2Str(Date.today());
        String rtn = null;
        if (dt == null) {
            return rtn;
        }
        rtn = String.valueOf(dt);
        rtn = rtn.replaceAll('-', '');
        if (rtn >= '40001231') {
            rtn = '99991231';
        } else if (rtn < '19000101') {
            rtn = '19000101';
        }
        return rtn + '000000';
    }
    //上班结束时间
    public static String UpEndDt(){
        String dt = NFMUtil.formatDate2Str(Date.today());
        String rtn = null;
        if (dt == null) {
            return rtn;
        }
        rtn = String.valueOf(dt);
        rtn = rtn.replaceAll('-', '');
        if (rtn >= '40001231') {
            rtn = '99991231';
        } else if (rtn < '19000101') {
            rtn = '19000101';
        }
        return rtn + '084459';
    }
    //上班定义时间
    public static String UpDt(){
        String dt = NFMUtil.formatDate2Str(Date.today());
        String rtn = null;
        if (dt == null) {
            return rtn;
        }
        rtn = String.valueOf(dt);
        rtn = rtn.replaceAll('-', '');
        if (rtn >= '40001231') {
            rtn = '99991231';
        } else if (rtn < '19000101') {
            rtn = '19000101';
        }
        return rtn + '090000';
    }
    //下班定义时间
    public static String DownDt(){
        String dt = NFMUtil.formatDate2Str(Date.today());
        String rtn = null;
        if (dt == null) {
            return rtn;
        }
        rtn = String.valueOf(dt);
        rtn = rtn.replaceAll('-', '');
        if (rtn >= '40001231') {
            rtn = '99991231';
        } else if (rtn < '19000101') {
            rtn = '19000101';
        }
        return rtn + '170000';
    }
    //报价日、初次报价日、RC修理品RC受理日(小程序)时间方法   zyh  20220315   end
 
}