高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
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
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
@isTest
private class NFM110WebServiceTest {
    static Account company;
    static Account section1;        // 呼吸科
    static Account section2;        // 消化科
    static Account olympus;
    static Account olympus1;        // 呼吸科
    static Account olympus2;        // 消化科
    static Account depart1;
    static Account depart2;
 
    static void initHpData() {
        RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        RecordType rectDpt1 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 呼吸科'];
        RecordType rectDpt2 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
        // テストデータ
        company = new Account(RecordTypeId = rectCo.Id, Name = 'NFM110TestCompany');
        olympus = new Account(RecordTypeId = rectCo.Id, AgentCode_Ext__c = '9999999', Name = 'olympus');
        insert new Account[] {company, olympus};
        company = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id =:company.Id];
        section1 = [select Management_Code__c, Management_Code_Auto__c, Name, Id, Department_Class_Label__c from Account where ParentId =:company.Id and RecordType.name = '戦略科室分類 呼吸科'];
        section2 = [select Management_Code__c, Management_Code_Auto__c, Name, Id, Department_Class_Label__c from Account where ParentId =:company.Id and RecordType.name = '戦略科室分類 消化科'];
        olympus1 = [select Management_Code__c, Management_Code_Auto__c, Name, Id, Department_Class_Label__c from Account where ParentId =:olympus.Id and RecordType.name = '戦略科室分類 呼吸科'];
        olympus2 = [select Management_Code__c, Management_Code_Auto__c, Name, Id, Department_Class_Label__c from Account where ParentId =:olympus.Id and RecordType.name = '戦略科室分類 消化科'];
System.debug('section1.Department_Class_Label__c='+section1.Department_Class_Label__c);
System.debug('section2.Department_Class_Label__c='+section2.Department_Class_Label__c);
        depart1 = new Account(RecordTypeId = rectDpt1.Id, Name = '*', ParentId  = section1.Id, Department_Class__c = section1.Id, Hospital__c = company.Id,
                Department_Name__c = 'NFM110TestDepart1');
        depart2 = new Account(RecordTypeId = rectDpt2.Id, Name = '*', ParentId  = section2.Id, Department_Class__c = section2.Id, Hospital__c = company.Id,
                Department_Name__c = 'NFM110TestDepart2');
        Account ocm = new Account(RecordTypeId = rectDpt2.Id, Name = '*', ParentId  = section2.Id, Department_Class__c = section2.Id, Hospital__c = company.Id,
                AgentCode_Ext__c = '9999900', Department_Name__c = 'NFM110TestDepart3');
        Account olympus_return = new Account(RecordTypeId = rectDpt2.Id, Name = '*', ParentId  = olympus2.Id, Department_Class__c = olympus2.Id, Hospital__c = olympus.Id,
                AgentCode_Ext__c = '9999901', Department_Name__c = 'olympus_return');
        insert new Account[] {depart1, depart2, ocm, olympus_return};
        depart1 = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id =:depart1.Id];
        depart2 = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id =:depart2.Id];
    }
    
    @isTest
    static void test_void() {
        initHpData();
        Product2 prd = new Product2(Name = 'NFM110Prd1', ProductCode = 'NFM110Prd1', ProductCode_Ext__c = 'NFM110Prd1', Manual_Entry__c = false);
        insert prd;
        Product2__c pro1 = new Product2__c(Name='NFM110Prd1',OT_CODE_Text__c='NFM110Prd1',Product2__c=prd.id);
        insert pro1;
        // null
        NFM110WebService.NFM110(null);
 
        NFM110WebService.GeneralData generalData1 = new NFM110WebService.GeneralData();
        NFM110WebService.ProductsDelivery ProductsDelivery = new NFM110WebService.ProductsDelivery();
        
        // Monitoringをセットしない
        NFM110WebService.NFM110(ProductsDelivery);
        
        Datetime nowDT = Datetime.now();
        String nowStr = nowDT.format('yyyyMMddHHmm');
        ProductsDelivery.Monitoring = new NFMUtil.Monitoring();
        ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '01';
        // GeneralDataをセットしない
        NFM110WebService.NFM110(ProductsDelivery);
 
        ProductsDelivery.GeneralData = new NFM110WebService.GeneralData[] { generalData1 };
        // generalData1.DeliveryNoteをセットしない
        ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '02';
        NFM110WebService.NFM110(ProductsDelivery);
 
        generalData1.DeliveryNote = 'DeliveryNote';
        // DnInformationをセットしない
        ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '03';
        NFM110WebService.NFM110(ProductsDelivery);
 
        NFM110WebService.DnInformation dnInfo1 = new NFM110WebService.DnInformation();
        generalData1.DnInformation = new NFM110WebService.DnInformation[] { dnInfo1 };
        // 病院と診療科の管理コードをセットしない
        ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '04';
        NFM110WebService.NFM110(ProductsDelivery);
 
        generalData1.EndUserNo       = 'NFM110TestABCD';
        generalData1.DepartmentNo    = 'NFM110TestDCBA';
        // 病院と診療科の管理コードが存在しない
        ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '05';
        NFM110WebService.NFM110(ProductsDelivery);
        generalData1.EndUserNo       = company.Management_Code_Auto__c;
        // 診療科の管理コードが存在しない
        ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '06';
        NFM110WebService.NFM110(ProductsDelivery);
 
        generalData1.EndUserNo       = company.Management_Code_Auto__c;
        generalData1.DepartmentNo    = depart1.Management_Code_Auto__c;
        // DnInformationの必須項目をセットしない
        ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '07';
        NFM110WebService.NFM110(ProductsDelivery);
 
        dnInfo1.SorLMark        = 'S';
        // DnInformationの必須項目をセットしない
        ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '08';
        NFM110WebService.NFM110(ProductsDelivery);
 
        dnInfo1.OTCode          = 'NFM110Prd1';
        // DnInformationの必須項目をセットしない
        ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '09';
        NFM110WebService.NFM110(ProductsDelivery);
 
        dnInfo1.OTCode          = 'NFM110TstPrd1234';
        dnInfo1.SerialNoorLotNo = '2577010001675';
        // 商品コードが存在しない
        ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '10';
        NFM110WebService.NFM110(ProductsDelivery);
 
        Asset[] rslts = [select Id from Asset];
        System.assertEquals(0, rslts.size());
    }
    
    @isTest
    static void test_insert() {
        initHpData();
        Product2 prd = new Product2(Name = 'NFM110Prd1', ProductCode = 'NFM110Prd1', ProductCode_Ext__c = 'NFM110Prd1', Manual_Entry__c = false);
        insert prd;
        Product2__c pro1 = new Product2__c(Name='NFM110Prd1',OT_CODE_Text__c='NFM110Prd1',Product2__c=prd.id);
        insert pro1;
 
        NFM110WebService.GeneralData generalData1 = new NFM110WebService.GeneralData();
        NFM110WebService.ProductsDelivery ProductsDelivery = new NFM110WebService.ProductsDelivery();
 
        Datetime nowDT = Datetime.now();
        String nowStr = nowDT.format('yyyyMMddHHmm');
        ProductsDelivery.Monitoring = new NFMUtil.Monitoring();
        ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '01';
 
        ProductsDelivery.GeneralData = new NFM110WebService.GeneralData[] { generalData1 };
        generalData1.DeliveryNote = 'DeliveryNote';
        NFM110WebService.DnInformation dnInfo1 = new NFM110WebService.DnInformation();
        generalData1.DnInformation = new NFM110WebService.DnInformation[] { dnInfo1 };
        generalData1.EndUserNo     = company.Management_Code_Auto__c;
        generalData1.DepartmentNo  = depart1.Management_Code_Auto__c;
        dnInfo1.SorLMark        = 'S';
        dnInfo1.OTCode          = prd.ProductCode_Ext__c;
        dnInfo1.SerialNoorLotNo = '2577010001675';
 
        System.Test.startTest();
        NFM110WebService.NFM110(ProductsDelivery);
        System.Test.stopTest();
 
        Asset[] rslts = [select Id, Return_Flag__c, AccountId, Department_Class__c, Hospital__c, Product2Id, SerialNumber, SLMark__c, IF_Information_From__c, InstallDate from Asset];
        List<BatchIF_Log__c> rowbl = [Select Id, Log__c, ErrorLog__c from BatchIF_Log__c where RowDataFlg__c = false and Type__c = 'NFM110' order by CreatedDate desc];
        //System.assertEquals('1', rowbl[0].ErrorLog__c);
        System.assertEquals(1, rslts.size());
        if(rslts.size() > 0){
            System.assertEquals(1, rslts.size());
            System.assertEquals(false, rslts[0].Return_Flag__c);
            System.assertEquals(depart1.Id, rslts[0].AccountId);
            System.assertEquals(section1.Id, rslts[0].Department_Class__c);
            System.assertEquals(company.Id, rslts[0].Hospital__c);
            System.assertEquals(prd.Id, rslts[0].Product2Id);
            System.assertEquals(dnInfo1.SerialNoorLotNo, rslts[0]. SerialNumber);
            System.assertEquals('Serial Number', rslts[0]. SLMark__c);
            System.assertEquals(true, rslts[0]. IF_Information_From__c);
            System.assertEquals(null, rslts[0]. InstallDate);
        }
        
    }
    
    // DepartmentNo = null
    @isTest
    static void test_insert_01() {
        initHpData();
        Product2 prd = new Product2(Name = 'NFM110Prd1', ProductCode = 'NFM110Prd1', ProductCode_Ext__c = 'NFM110Prd1', Manual_Entry__c = false);
        insert prd;
        Product2__c pro1 = new Product2__c(Name='NFM110Prd1',OT_CODE_Text__c='NFM110Prd1',Product2__c=prd.id);
        insert pro1;
        Opportunity opp = new Opportunity(Name='aiueo', StageName='出荷', CloseDate=Date.today());
        insert opp;
        Opportunity[] opps = [select Id, Name, Opportunity_No__c from Opportunity where Id = :opp.Id ];
        Statu_Achievements__c sta = new Statu_Achievements__c(
            Name='test01',
            Opportunity__c = opp.Id,
            DeliveryStatus__c = 'test',
            PaymentRate__c = '1234',
            ContractAmount__c = 0,
            End_User_price__c = 0,
            AssignmentStatus__c = '全部分配',
            Last_week__c = '5 货齐,未付款,无用户合同',
            X2weeks_ago__c = '4 备货中',
            X3Weeks_ago__c = '3 已付款,无用户合同',
            X4weeks_ago__c = '2 待付款',
            X5weeks_ago__c = '1 全没有'
        );
        insert sta;
 
 
        NFM110WebService.GeneralData generalData1 = new NFM110WebService.GeneralData();
        NFM110WebService.ProductsDelivery ProductsDelivery = new NFM110WebService.ProductsDelivery();
        
        Datetime nowDT = Datetime.now();
        String nowStr = nowDT.format('yyyyMMddHHmm');
        ProductsDelivery.Monitoring = new NFMUtil.Monitoring();
        ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '01';
 
        ProductsDelivery.GeneralData = new NFM110WebService.GeneralData[] { generalData1 };
        generalData1.DeliveryNote = 'DeliveryNote';
        NFM110WebService.DnInformation dnInfo1 = new NFM110WebService.DnInformation();
        generalData1.DnInformation = new NFM110WebService.DnInformation[] { dnInfo1 };
        generalData1.EndUserNo     = company.Management_Code_Auto__c;
        generalData1.DepartmentNo  = null;
        generalData1.SoNo          = sta.Name;
        generalData1.InquiryNo     = opps[0].Opportunity_No__c + ',';
        dnInfo1.SorLMark        = 'S';
        dnInfo1.OTCode          = prd.ProductCode_Ext__c;
        dnInfo1.SerialNoorLotNo = '2577010001675';
        
        System.Test.startTest();
        NFM110WebService.NFM110(ProductsDelivery);
        System.Test.stopTest();
 
        Asset[] rslts = [select Id, Hospital__c, AccountId, Product2Id, Backorder__c from Asset];
        //System.assertEquals(1, rslts.size());
        //System.assertEquals(company.Id, rslts[0].Hospital__c);
        //System.assertEquals(company.Id, rslts[0].AccountId);
        //System.assertEquals(prd.Id, rslts[0].Product2Id);
        //System.assertEquals(sta.Id, rslts[0].Backorder__c);
    }
 
    @isTest
    static void coc_test() {
        initHpData();
 
        List<RecordType> conOrder_Order = [select Id from RecordType where IsActive = true and SobjectType = 'Consumable_order__c' and Name = '01 订单'];
        if (conOrder_Order.size() == 0) {
            return;
        }
 
        List<RecordType> conOrderDetail_Order = [select Id from RecordType where IsActive = true and SobjectType = 'Consumable_orderdetails__c' and Name = '订单'];
        if (conOrderDetail_Order.size() == 0) {
            return;
        }
 
        Product2 prd = new Product2(Name = 'NFM110Prd1', ProductCode = 'NFM110Prd1', ProductCode_Ext__c = 'NFM110Prd1', Manual_Entry__c = false);
        insert prd;
 
        Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='NFM110Prd1',Product2__c=prd.id);
        insert pro1;
 
        Consumable_order__c coc = new Consumable_order__c(Name = 'Name001',Order_status__c = '批准',RecordTypeid = conOrder_Order[0].Id);
        insert coc;
        Consumable_orderdetails__c codc = new Consumable_orderdetails__c(Name='orderdetails001',Consumable_order__c = coc.id,Consumable_Product__c =pro1.id,RecordTypeId =conOrderDetail_Order[0].Id);
        insert codc;
 
        NFM110WebService.GeneralData generalData1 = new NFM110WebService.GeneralData();
        NFM110WebService.ProductsDelivery ProductsDelivery = new NFM110WebService.ProductsDelivery();
        
        Datetime nowDT = Datetime.now();
        String nowStr = nowDT.format('yyyyMMddHHmm');
        ProductsDelivery.Monitoring = new NFMUtil.Monitoring();
        ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '01';
 
        ProductsDelivery.GeneralData = new NFM110WebService.GeneralData[] { generalData1 };
        generalData1.DeliveryNote = 'DeliveryNote';
        NFM110WebService.DnInformation dnInfo1 = new NFM110WebService.DnInformation();
        generalData1.DnInformation = new NFM110WebService.DnInformation[] { dnInfo1 };
        generalData1.EndUserNo     = company.Management_Code_Auto__c;
        generalData1.DepartmentNo  = depart1.Management_Code_Auto__c;
        //generalData1.SoNo = coc.Name;
        generalData1.InquiryNo = coc.Name + ',';
        dnInfo1.SorLMark        = 'S';
        dnInfo1.OTCode          = pro1.OT_CODE_Text__c;
        dnInfo1.SerialNoorLotNo = '2577010001675';
 
        
        System.Test.startTest();
        NFM110WebService.NFM110(ProductsDelivery);
        System.Test.stopTest();
 
        Consumable_order__c[] coc1 = [select id,name from Consumable_order__c where id =:coc.id];
        System.assertEquals(1, coc1.size());
    }
    
    @isTest
    static void test_update() {
        User loginUser = [Select Id, Alias, Province__c from User where Id =: UserInfo.getUserId()];
        loginUser.Batch_User__c = true;
        loginUser.responsibility__c = '华北营业一部';
        loginUser.OCM_Management_Province__c = '北京';
        update loginUser;
 
        initHpData();
        Product2 prd = new Product2(Name = 'NFM110Prd1', ProductCode = 'NFM110Prd1', ProductCode_Ext__c = 'NFM110Prd1', Manual_Entry__c = false,MDM_Model_No__c = 'NFM110Ast1');
        insert prd;
        Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='NFM110Prd1',Product2__c = prd.Id);
        insert pro1;
        Asset ast = new Asset(Name='NFM110Ast1', AccountId=depart1.Id, Department_Class__c=section1.Id, Hospital__c=company.Id, Product2Id=prd.Id,
            SerialNumber='2577010001675', Guarantee_period_for_products__c=Date.today()
        );
        insert ast;
        Opportunity opp1 = new Opportunity(Name='aiueo1', StageName='出荷', CurrencyIsoCode='CNY', CloseDate=Date.today());
        insert opp1;
        Statu_Achievements__c sta11 = new Statu_Achievements__c(Name='SO0000001', Opportunity__c=opp1.Id, ContractNO__c='sta11', DeliveryStatus__c = '未交付',ContractAmount__c = 0);
        insert sta11;
 
        NFM110WebService.GeneralData generalData1 = new NFM110WebService.GeneralData();
        NFM110WebService.ProductsDelivery ProductsDelivery = new NFM110WebService.ProductsDelivery();
        
        Datetime nowDT = Datetime.now();
        String nowStr = nowDT.format('yyyyMMddHHmm');
        ProductsDelivery.Monitoring = new NFMUtil.Monitoring();
        ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '01';
 
        ProductsDelivery.GeneralData = new NFM110WebService.GeneralData[] { generalData1 };
        generalData1.DeliveryNote = 'DeliveryNote';
        NFM110WebService.DnInformation dnInfo1 = new NFM110WebService.DnInformation();
        generalData1.DnInformation = new NFM110WebService.DnInformation[] { dnInfo1 };
        generalData1.EndUserNo     = company.Management_Code_Auto__c;
        generalData1.DepartmentNo  = depart1.Management_Code_Auto__c;
        generalData1.SoNo = sta11.Name;
        generalData1.InquiryNo = sta11.Name + ',';
        dnInfo1.SorLMark        = 'S';
        dnInfo1.OTCode          = prd.ProductCode_Ext__c;
        dnInfo1.Barcode          = 'testbarcode001';
        dnInfo1.SerialNoorLotNo = ast.SerialNumber;
        
        System.Test.startTest();
        NFM110WebService.NFM110(ProductsDelivery);
        
        List<Product2> prdList = [select Id, Name, ProductCode, ProductCode_Ext__c, MDM_Model_No__c
                                        from Product2
                                       where ProductCode_Ext__c = :prd.ProductCode_Ext__c];
        System.assertEquals(1, prdList.size());
        Asset[] rslts = [select Id, Return_Flag__c from Asset where Id=:ast.Id];
        System.assertEquals(1, rslts.size());
 
        // retry_cnt__c がクリアされること
        List<BatchIF_Log__c> rowbl = [Select Id, Log__c, ErrorLog__c from BatchIF_Log__c where RowDataFlg__c = true and Type__c = 'NFM110' order by CreatedDate desc];
        System.assertEquals(1, rowbl.size());
        rowbl[0].retry_cnt__c = 1;
        update rowbl;
        NFM110WebService.execute(rowbl[0].id);
        System.Test.stopTest();
        List<BatchIF_Log__c> bl = [Select Id, Is_Error__c,
                Type__c, Log__c, ErrorLog__c,retry_cnt__c
                from BatchIF_Log__c
                where Id = :rowbl[0].id];
        System.assertEquals(0, bl[0].retry_cnt__c);
    }
    
    @isTest
    static void test_delete() {
        User loginUser = [Select Id, Alias, Province__c from User where Id =: UserInfo.getUserId()];
        loginUser.Batch_User__c = true;
        loginUser.responsibility__c = '华北营业一部';
        loginUser.OCM_Management_Province__c = '北京';
        update loginUser;
 
        initHpData();
        Product2 prd = new Product2(Name = 'NFM110Prd1', ProductCode = 'NFM110Prd1', ProductCode_Ext__c = 'NFM110Prd1', Manual_Entry__c = false);
        insert prd;
        Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='NFM110Prd1',Product2__c=prd.id);
        insert pro1;
        Asset ast = new Asset(Name='NFM110Ast1', AccountId=depart1.Id, Department_Class__c=section1.Id, Hospital__c=company.Id, Product2Id=prd.Id,
            SerialNumber='2577010001675', Guarantee_period_for_products__c=Date.today()
        );
        insert ast;
        Opportunity opp1 = new Opportunity(Name='aiueo1', StageName='出荷', CurrencyIsoCode='CNY', CloseDate=Date.today());
        insert opp1;
        Statu_Achievements__c sta11 = new Statu_Achievements__c(Name='SO0000001', Opportunity__c=opp1.Id, ContractNO__c='sta11', DeliveryStatus__c = '未交付',ContractAmount__c = 0);
        insert sta11;
 
        NFM110WebService.GeneralData generalData1 = new NFM110WebService.GeneralData();
        NFM110WebService.ProductsDelivery ProductsDelivery = new NFM110WebService.ProductsDelivery();
        
        Datetime nowDT = Datetime.now();
        String nowStr = nowDT.format('yyyyMMddHHmm');
        ProductsDelivery.Monitoring = new NFMUtil.Monitoring();
        ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '01';
 
        ProductsDelivery.GeneralData = new NFM110WebService.GeneralData[] { generalData1 };
        generalData1.DeliveryNote = 'DeliveryNote';
        NFM110WebService.DnInformation dnInfo1 = new NFM110WebService.DnInformation();
        generalData1.DnInformation = new NFM110WebService.DnInformation[] { dnInfo1 };
        generalData1.EndUserNo     = company.Management_Code_Auto__c;
        generalData1.DepartmentNo  = depart1.Management_Code_Auto__c;
        generalData1.SoNo = sta11.Name;
        generalData1.InquiryNo = sta11.Name + ',';
        generalData1.ReturnMark    = '1';
        dnInfo1.SorLMark        = 'S';
        dnInfo1.OTCode          = prd.ProductCode_Ext__c;
        dnInfo1.SerialNoorLotNo = ast.SerialNumber;
        
        System.Test.startTest();
        NFM110WebService.NFM110(ProductsDelivery);
        System.Test.stopTest();
 
        Asset[] rslts = [select Id, Return_Flag__c from Asset where Id=:ast.Id];
        System.assertEquals(1, rslts.size());
        //System.assertEquals(true, rslts[0].Return_Flag__c);
    }
 
    @isTest
    static void coc_send() {
        initHpData();
 
        List<RecordType> conOrder_Order = [select Id from RecordType where IsActive = true and SobjectType = 'Consumable_order__c' and Name = '01 订单'];
        if (conOrder_Order.size() == 0) {
            return;
        }
 
        List<RecordType> conOrderDetail_Order = [select Id from RecordType where IsActive = true and SobjectType = 'Consumable_orderdetails__c' and Name = '订单'];
        if (conOrderDetail_Order.size() == 0) {
            return;
        }
 
        Product2 prd = new Product2(Name = 'NFM110Prd1', ProductCode = 'NFM110Prd1', ProductCode_Ext__c = 'NFM110Prd1', Manual_Entry__c = false);
        insert prd;
 
        Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='NFM110Prd1',Product2__c=prd.id);
        insert pro1;
 
        Consumable_order__c coc = new Consumable_order__c(Name = 'Name001',Order_status__c = '批准',RecordTypeid = conOrder_Order[0].Id);
        insert coc;
        Consumable_orderdetails__c codc = new Consumable_orderdetails__c(Name='orderdetails001',Consumable_order__c = coc.id,Consumable_Product__c =pro1.id,RecordTypeId =conOrderDetail_Order[0].Id);
        insert codc;
 
        NFM110WebService.GeneralData generalData1 = new NFM110WebService.GeneralData();
        NFM110WebService.ProductsDelivery ProductsDelivery = new NFM110WebService.ProductsDelivery();
        
        Datetime nowDT = Datetime.now();
        String nowStr = nowDT.format('yyyyMMddHHmm');
        ProductsDelivery.Monitoring = new NFMUtil.Monitoring();
        ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '01';
 
        ProductsDelivery.GeneralData = new NFM110WebService.GeneralData[] { generalData1 };
        generalData1.DeliveryNote = 'DeliveryNote';
        NFM110WebService.DnInformation dnInfo1 = new NFM110WebService.DnInformation();
        generalData1.DnInformation = new NFM110WebService.DnInformation[] { dnInfo1 };
        generalData1.EndUserNo     = company.Management_Code_Auto__c;
        generalData1.DepartmentNo  = depart1.Management_Code_Auto__c;
        //generalData1.SoNo = coc.Name;
        generalData1.InquiryNo =  'Name001,';
        dnInfo1.SorLMark        = 'S';
        dnInfo1.OTCode          = pro1.OT_CODE_Text__c;
        dnInfo1.SerialNoorLotNo = '2577010001675';
 
        
        System.Test.startTest();
        NFM110WebService.NFM110(ProductsDelivery);
        System.Test.stopTest();
 
        Consumable_order__c[] coc1 = [select id,name from Consumable_order__c where id =:coc.id];
        System.assertEquals(1, coc1.size());
    }
    @isTest
    static void coc_consumable() {
        initHpData();
 
        List<RecordType> conOrder_Order = [select Id from RecordType where IsActive = true and SobjectType = 'Consumable_order__c' and Name = '01 订单'];
        if (conOrder_Order.size() == 0) {
            return;
        }
 
        List<RecordType> conOrderDetail_Order = [select Id from RecordType where IsActive = true and SobjectType = 'Consumable_orderdetails__c' and Name = '订单'];
        if (conOrderDetail_Order.size() == 0) {
            return;
        }
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectCotac = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '契約'];
        if (rectCotac.size() == 0) {
            return;
        }
        //测试经销商信息
        Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id,Product_Limit_Date__c = 'Test01|5|55,Test02|2|4');
        insert myAccount2;
        //测试合同信息
        Account contact = new Account(name='Testaccount002', RecordTypeId = rectCotac[0].Id,SpecialDealerName__c = 'Testaccount002',
                                      ParentId = myAccount2.Id,Agent_Ref__c = myAccount2.Id,Delete_Flag__c = false,
                                      Contract_Department_Class__c = 'ET',Contract_Decide_Start_Date__c = Date.today().addDays(-1),
                                      Contract_Decide_End_Date__c = Date.today().addDays(1),AgencyContract_Management_Code__c = '5555555');
        insert contact;
        contact = [select Management_Code__c from Account where id = :contact.Id];
 
        Product2 prd = new Product2(Name = 'NFM110Prd1', ProductCode = 'NFM110Prd1', ProductCode_Ext__c = 'NFM110Prd1', Manual_Entry__c = false,Dealer_special_Object__c = true);
        insert prd;
 
        Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='NFM110Prd1',Product2__c=prd.id);
        insert pro1;
 
        Consumable_order__c coc = new Consumable_order__c(Name = 'Name001',Order_status__c = '批准',RecordTypeid = conOrder_Order[0].Id);
        insert coc;
        Consumable_orderdetails__c codc = new Consumable_orderdetails__c(Name='orderdetails001',Consumable_order__c = coc.id,Consumable_Product__c =pro1.id,RecordTypeId =conOrderDetail_Order[0].Id,Consumable_count__c = 1);
        insert codc;
 
        NFM110WebService.GeneralData generalData1 = new NFM110WebService.GeneralData();
        NFM110WebService.ProductsDelivery ProductsDelivery = new NFM110WebService.ProductsDelivery();
        
        Datetime nowDT = Datetime.now();
        String nowStr = nowDT.format('yyyyMMddHHmm');
        ProductsDelivery.Monitoring = new NFMUtil.Monitoring();
        ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '01';
 
        ProductsDelivery.GeneralData = new NFM110WebService.GeneralData[] { generalData1 };
        generalData1.DeliveryNote = 'DeliveryNote';
        NFM110WebService.DnInformation dnInfo1 = new NFM110WebService.DnInformation();
        generalData1.DnInformation = new NFM110WebService.DnInformation[] { dnInfo1 };
        generalData1.EndUserNo     = contact.Management_Code__c;
        generalData1.DepartmentNo  = contact.Management_Code__c;
        //generalData1.SoNo = coc.Name;
        generalData1.InquiryNo  =  'Name001,Name001';
        dnInfo1.SorLMark        = 'L';
        dnInfo1.OTCode          = pro1.OT_CODE_Text__c;
        dnInfo1.SerialNoorLotNo = '85K';
        dnInfo1.Barcode         = 'testbarcode001250AAAAA';
        dnInfo1.TracingCode     = 'AAAAA';
        
        System.Test.startTest();
        NFM110WebService.NFM110(ProductsDelivery);
        System.Test.stopTest();
 
        Consumable_order__c[] coc1 = [select id,name from Consumable_order__c where id =:coc.id];
        System.assertEquals(1, coc1.size());
        //List<BatchIF_Log__c> rowbl = [Select Id, Log__c, ErrorLog__c from BatchIF_Log__c where RowDataFlg__c = false and Type__c = 'NFM110' order by CreatedDate desc];
        //System.assertEquals('1', rowbl[0].ErrorLog__c);
        Consumable_order_details2__c[] cod2 = [select id,name from Consumable_order_details2__c where Consumable_order_minor__c =:coc.id];
        System.assertEquals(1, cod2.size());
        
    }
    
    @isTest
    static void coc_consumable_InquiryNo() {
        initHpData();
 
        List<RecordType> conOrder_Order = [select Id from RecordType where IsActive = true and SobjectType = 'Consumable_order__c' and Name = '01 订单'];
        if (conOrder_Order.size() == 0) {
            return;
        }
 
        List<RecordType> conOrderDetail_Order = [select Id from RecordType where IsActive = true and SobjectType = 'Consumable_orderdetails__c' and Name = '订单'];
        if (conOrderDetail_Order.size() == 0) {
            return;
        }
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectCotac = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '契約'];
        if (rectCotac.size() == 0) {
            return;
        }
        //测试经销商信息
        Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id,Product_Limit_Date__c = 'Test01|5|55,Test02|2|4');
        insert myAccount2;
        //测试合同信息
        Account contact = new Account(name='Testaccount002', RecordTypeId = rectCotac[0].Id,SpecialDealerName__c = 'Testaccount002',ParentId = myAccount2.Id,Agent_Ref__c = myAccount2.Id,Delete_Flag__c = false,Contract_Department_Class__c = 'ET',Contract_Decide_Start_Date__c = Date.today().addDays(-1),Contract_Decide_End_Date__c = Date.today().addDays(1));
        insert contact;
        contact = [select Management_Code__c from Account where id = :contact.Id];
        //System.assertEquals('99999', contact.Management_Code__c);
        Product2 prd = new Product2(Name = 'NFM110Prd1', ProductCode = 'NFM110Prd1', ProductCode_Ext__c = 'NFM110Prd1', Manual_Entry__c = false,Dealer_special_Object__c = true);
        insert prd;
 
        Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='NFM110Prd1',Product2__c=prd.id);
        insert pro1;
 
        Consumable_order__c coc = new Consumable_order__c(Name = 'Name002',Order_status__c = '批准',RecordTypeid = conOrder_Order[0].Id);
        insert coc;
        Consumable_orderdetails__c codc = new Consumable_orderdetails__c(Name='orderdetails001',Consumable_order__c = coc.id,Consumable_Product__c =pro1.id,RecordTypeId =conOrderDetail_Order[0].Id,Consumable_count__c = 1);
        insert codc;
 
        NFM110WebService.GeneralData generalData1 = new NFM110WebService.GeneralData();
        NFM110WebService.ProductsDelivery ProductsDelivery = new NFM110WebService.ProductsDelivery();
        
        Datetime nowDT = Datetime.now();
        String nowStr = nowDT.format('yyyyMMddHHmm');
        ProductsDelivery.Monitoring = new NFMUtil.Monitoring();
        ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '01';
 
        ProductsDelivery.GeneralData = new NFM110WebService.GeneralData[] { generalData1 };
        generalData1.DeliveryNote = 'DeliveryNote';
        NFM110WebService.DnInformation dnInfo1 = new NFM110WebService.DnInformation();
        generalData1.DnInformation = new NFM110WebService.DnInformation[] { dnInfo1 };
        generalData1.EndUserNo     = '000' + contact.Management_Code__c;
        generalData1.DepartmentNo  = '000' + contact.Management_Code__c;
        //generalData1.SoNo = coc.Name;
        generalData1.InquiryNo  =  'Name002,Name002';
        dnInfo1.SorLMark        = 'L';
        dnInfo1.OTCode          = pro1.OT_CODE_Text__c;
        dnInfo1.SerialNoorLotNo = '85K';
        dnInfo1.Barcode         = 'testbarcode001250AAAAA';
        dnInfo1.TracingCode     = 'AAAAA';
 
        
        System.Test.startTest();
        NFM110WebService.NFM110(ProductsDelivery);
        System.Test.stopTest();
 
        Consumable_order__c[] coc1 = [select id,name from Consumable_order__c where id =:coc.id];
        System.assertEquals(1, coc1.size());
        List<BatchIF_Log__c> rowbl = [Select Id, Log__c, ErrorLog__c from BatchIF_Log__c where RowDataFlg__c = false and Type__c = 'NFM110' order by CreatedDate desc];
        //System.assertEquals('1', rowbl[0].ErrorLog__c);
        Consumable_order_details2__c[] cod2 = [select id,name from Consumable_order_details2__c];
        System.assertEquals(1, cod2.size());
    }
    @isTest
    //直接到货再入库对应
    static void coc_doubleArrive() {
        initHpData();
        StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
        List<RecordType> conOrder_Order = [select Id from RecordType where IsActive = true and SobjectType = 'Consumable_order__c' and Name = '01 订单'];
        if (conOrder_Order.size() == 0) {
            return;
        }
 
        List<RecordType> conOrderDetail_Order = [select Id from RecordType where IsActive = true and SobjectType = 'Consumable_orderdetails__c' and Name = '订单'];
        if (conOrderDetail_Order.size() == 0) {
            return;
        }
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectCotac = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '契約'];
        if (rectCotac.size() == 0) {
            return;
        }
        //测试经销商信息
        Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id,Product_Limit_Date__c = 'Test01|5|55,Test02|2|4');
        insert myAccount2;
        //测试合同信息
        Account contact = new Account(name='Testaccount002', RecordTypeId = rectCotac[0].Id,SpecialDealerName__c = 'Testaccount002',ParentId = myAccount2.Id,Agent_Ref__c = myAccount2.Id,Delete_Flag__c = false,Contract_Department_Class__c = 'ET',Contract_Decide_Start_Date__c = Date.today().addDays(-1),Contract_Decide_End_Date__c = Date.today().addDays(1));
        insert contact;
        contact = [select Management_Code__c from Account where id = :contact.Id];
 
        Product2 prd = new Product2(Name = 'NFM110Prd1', ProductCode = 'NFM110Prd1', ProductCode_Ext__c = 'NFM110Prd1', Manual_Entry__c = false,Dealer_special_Object__c = true);
        insert prd;
 
        Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='NFM110Prd1',Product2__c=prd.id);
        insert pro1;
 
        Consumable_order__c coc = new Consumable_order__c(Name = 'Name001',Order_status__c = '批准',RecordTypeid = conOrder_Order[0].Id);
        insert coc;
        Consumable_orderdetails__c codc = new Consumable_orderdetails__c(Name='orderdetails001',Consumable_order__c = coc.id,Consumable_Product__c =pro1.id,RecordTypeId =conOrderDetail_Order[0].Id);
        insert codc;
        Consumable_order_details2__c codc2 = new Consumable_order_details2__c(Name='det2001',Consumable_order_minor__c = coc.id,Consumable_Product__c =pro1.id,RecordTypeId =System.Label.RT_ConOrderDetail2_Delivery,
                                              Asset_Model_No__c = 'NFM110Prd1',Bar_Code__c = 'testbarcode0011085K250AAAAA',Arrive_date__c = Date.today(),Direct_Arrive_Product__c = true,TracingCode__c = 'AAAAA',SerialLotNo__c = '85K');
        insert codc2;
 
        NFM110WebService.GeneralData generalData1 = new NFM110WebService.GeneralData();
        NFM110WebService.ProductsDelivery ProductsDelivery = new NFM110WebService.ProductsDelivery();
        
        Datetime nowDT = Datetime.now();
        String nowStr = nowDT.format('yyyyMMddHHmm');
        ProductsDelivery.Monitoring = new NFMUtil.Monitoring();
        ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '01';
 
        ProductsDelivery.GeneralData = new NFM110WebService.GeneralData[] { generalData1 };
        generalData1.DeliveryNote = 'DeliveryNote';
        NFM110WebService.DnInformation dnInfo1 = new NFM110WebService.DnInformation();
        generalData1.DnInformation = new NFM110WebService.DnInformation[] { dnInfo1 };
        generalData1.EndUserNo     = contact.Management_Code__c;
        generalData1.DepartmentNo  = contact.Management_Code__c;
        //generalData1.SoNo = coc.Name;
        generalData1.InquiryNo  =  'Name001,Name001';
        dnInfo1.SorLMark        = 'L';
        dnInfo1.OTCode          = pro1.OT_CODE_Text__c;
        dnInfo1.SerialNoorLotNo = '85K';
        dnInfo1.Barcode         = 'testbarcode0011085K250AAAAA';
        dnInfo1.TracingCode     = 'AAAAA';
 
        
        System.Test.startTest();
        NFM110WebService.NFM110(ProductsDelivery);
        System.Test.stopTest();
 
        Consumable_order_details2__c[] cod2 = [select id,name,Direct_Arrive_Product__c from Consumable_order_details2__c];
        System.assertEquals(1, cod2.size());
        System.assertEquals(false, cod2[0].Direct_Arrive_Product__c);
        //List<BatchIF_Log__c> rowbl = [Select Id, Log__c, ErrorLog__c from BatchIF_Log__c where RowDataFlg__c = false and Type__c = 'NFM110' order by CreatedDate desc];
        //System.assertEquals('1', rowbl[0].ErrorLog__c);
    }
 
    //促销产品
    static testMethod void coc_romotionPro() {
        initHpData();
        StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
        List<RecordType> conOrder_Order = [select Id from RecordType where IsActive = true and SobjectType = 'Consumable_order__c' and Name = '01 订单'];
        if (conOrder_Order.size() == 0) {
            return;
        }
 
        List<RecordType> conOrderDetail_Order = [select Id from RecordType where IsActive = true and SobjectType = 'Consumable_orderdetails__c' and Name = '订单'];
        if (conOrderDetail_Order.size() == 0) {
            return;
        }
 
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
        if (rectCo.size() == 0) {
            return;
        }
 
        List<RecordType> rectContract = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '契約'];
        if (rectCo.size() == 0) {
            return;
        }
        Id pricebookId = ControllerUtil.getStandardPricebook().Id;
        // 产品
        Product2 prd1 = new Product2(
            Name='name01',
            IsActive=true,
            Asset_Model_No__c='NFM110Prd1',
            ProductCode = 'NFM110Prd1',
            ProductCode_Ext__c = 'NFM110Prd1',
            Manual_Entry__c=false,
            //SFDA_Status__c='有効',
            Intra_Trade_List_RMB_Date1__c=Date.today().addDays(-1),
            Intra_Trade_List_RMB_Date2__c=Date.today().addDays(-1),
            Intra_Trade_List_RMB_End_Date1__c=Date.today().addDays(1),
            Intra_Trade_List_RMB_End_Date2__c=Date.today().addDays(1),
            Intra_Trade_List_RMB_1__c=100,
            Intra_Trade_List_RMB_2__c=200,
            Intra_Trade_Cost_RMB_Date1__c=Date.today().addDays(-1),
            Intra_Trade_Cost_RMB_Date2__c=Date.today().addDays(-1),
            Intra_Trade_Cost_RMB_End_Date1__c=Date.today().addDays(1),
            Intra_Trade_Cost_RMB_End_Date2__c=Date.today().addDays(1),
            Intra_Trade_Cost_RMB_1__c=10,
            Intra_Trade_Cost_RMB_2__c=20,
            Dealer_special_Object__c = true,
            SFDA_Approbated_Status__c = '不要',
            Product_Status__c = '正常销售'
 
        );
        insert new Product2[] {prd1};
 
        // 価格表エントリを作成する
        PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=prd1.Id);
        entry.UnitPrice = 0;
        entry.IsActive = true;
        entry.UseStandardPrice = false;
        entry.CurrencyIsoCode = 'CNY';
        insert new PricebookEntry[] {entry};
        //经销商、联系人、用户信息
        Account myAccount1 = new Account(name='Testaccount001',
                                        Dealer_discount__c =20,
                                        Ban_On_Use_Date__c = Date.today().addDays(1),
                                        Business_Paper_Expiration_Date__c = Date.today().addDays(1),
                                        Tax_Practice_Expiration_Date__c = Date.today().addDays(1),
                                        Medical_Equipment_Expiration_Date__c = Date.today().addDays(1),
                                        RecordTypeId = rectCo[0].Id);
        insert myAccount1;
        //医疗器械经营许可证
        License_Information__c linc = new License_Information__c( name='Test20181204',
                                                LicenseType__c = '医疗器械经营许可证',
                                                BusinessLicense__c = '20180522',
                                                ValidFrom__c = date.newinstance(2018, 05, 22),
                                                ValidTo__c = date.newinstance(2088, 05, 22),
                                                Scope3__c = '6815;6822;6823;6825',
                                                LicenseAndAccount__c = myAccount1.Id
                                                );
        insert linc;
        Product_Register__c prc = new Product_Register__c(Name = '国械注进20162220210',
                                                MedPrdClass__c = '3',
                                                ValidFrom__c = date.newinstance(2018, 07, 22),
                                                ValidTo__c = date.newinstance(2028, 07, 22),
                                                RegisterNoClass_Old__c = '6815',
                                                RegisterNoClass_New__c = '6815',
                                                RegisterNoStatus__c = '不要'
                                                );
        insert prc;
        //新旧关系对照表
        Product_Register_contrast__c prcc = new Product_Register_contrast__c(
                                                Name = 'Test20181204',
                                                Register_new__c = '314',
                                                Register_old__c = '36815'
                                                );
        insert prcc;
        //产品-产品注册证关系
        Product_Register_Link__c  prlc = new Product_Register_Link__c(
                                                Product2__c = prd1.Id,
                                                Product_Register__c = prc.Id
                                                ); 
        insert prlc;
        Account acc1 = [select Id,Name,Is_Active_Formula__c from Account where Id = : myAccount1.Id];
        System.assertEquals('有效', acc1.Is_Active_Formula__c);
        //经销商有效合同
        Account myAccount2 = new Account(name='Testaccount002',
                                            RecordTypeId = rectContract[0].Id,
                                            Contract_Decide_Start_Date__c = Date.today().addDays(-1),
                                            Contract_Decide_End_Date__c =Date.today().addDays(1),
                                            Contract_Start_Date__c = Date.today().addDays(-1),
                                            Contract_End_Date__c =Date.today().addDays(1),
                                            Agent_Ref__c =myAccount1.Id,
                                            ET_SP_Dealer__c = true,
                                            Business_Assistant__c = UserInfo.getUserId(),
                                            ParentId =myAccount1.Id);
        insert myAccount2;
        Account acc2 = [select Id,Name,Management_Code__c,Is_Active_Formula__c from Account where Id = : myAccount2.Id];
        System.assertEquals('有效', acc2.Is_Active_Formula__c);
 
 
        Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='NFM110Prd1',Product2__c=prd1.id);
        //Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='NFM110Prd2',Product2__c=prd2.id);
        insert new Product2__c[] {pro1};
 
        Consumable_order__c coc = new Consumable_order__c(Name = 'Name001',
                                                            Dealer_Info__c = myAccount1.Id,
                                                            Order_status__c = '批准',
                                                            RecordTypeid = conOrder_Order[0].Id,
                                                            Contract_application_decision__c ='Name001'
                                                            ,SalesManager__c = UserInfo.getUserId(),
                                                            Order_effective_contact__c = myAccount2.Id
                                                            );
        insert coc;
        Consumable_orderdetails__c codc = new Consumable_orderdetails__c(Name='orderdetails001',                                                                            Consumable_order__c = coc.id,
                                                                            Consumable_Product__c =pro1.id,
                                                                            RecordTypeId =conOrderDetail_Order[0].Id,
                                                                            Consumable_count__c = 2,
                                                                            Intra_Trade_List_RMB__c = 100);
        insert codc;
        System.Test.startTest();
        SendConsumableordertosap.sendSAP(coc.id);
        //System.assertEquals('11111111', SendConsumableordertosap.sendSAP(coc.id));
        //System.Test.stopTest();
        //coc.Name= 'Name0011';
        //update coc;
        //Opportunity opp1 = new Opportunity(Name='aiueo10107', StageName='出荷', CurrencyIsoCode='CNY', CloseDate=Date.today(),Purchase_Type__c = 'ET24時間販売'
        //                     ,Sales_Root__c = '販売店');
        //insert opp1;
        Opportunity[] coc12 = [select id,Name,Opportunity_No__c,SAP_Province__c from Opportunity];
        System.assertEquals(1, coc12.size());
        
        NFM110WebService.GeneralData generalData1 = new NFM110WebService.GeneralData();
        NFM110WebService.ProductsDelivery ProductsDelivery = new NFM110WebService.ProductsDelivery();
        
        Datetime nowDT = Datetime.now();
        String nowStr = nowDT.format('yyyyMMddHHmm');
        ProductsDelivery.Monitoring = new NFMUtil.Monitoring();
        ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '01';
 
        ProductsDelivery.GeneralData = new NFM110WebService.GeneralData[] { generalData1 };
        generalData1.DeliveryNote = 'DeliveryNote';
        NFM110WebService.DnInformation dnInfo1 = new NFM110WebService.DnInformation();
        generalData1.DnInformation = new NFM110WebService.DnInformation[] { dnInfo1 };
        generalData1.EndUserNo     = acc2.Management_Code__c;
        generalData1.DepartmentNo  = acc2.Management_Code__c;
        //generalData1.SoNo = coc.Name;
        generalData1.InquiryNo  =   coc12[0].Opportunity_No__c + ',';
        dnInfo1.SorLMark        = 'L';
        dnInfo1.OTCode          = pro1.OT_CODE_Text__c;
        dnInfo1.SerialNoorLotNo = '85K';
        dnInfo1.Barcode         = 'testbarcode001250AAAAA';
        dnInfo1.TracingCode     = 'AAAAA';
 
        
        //System.Test.startTest();
        NFM110WebService.NFM110(ProductsDelivery);
        System.Test.stopTest();
 
        Consumable_order_details2__c[] cod2 = [select id,name,Direct_Arrive_Product__c from Consumable_order_details2__c];
        System.assertEquals(1, cod2.size());
        System.assertEquals(false, cod2[0].Direct_Arrive_Product__c);
        //List<BatchIF_Log__c> rowbl = [Select Id, Log__c, ErrorLog__c from BatchIF_Log__c where RowDataFlg__c = false and Type__c = 'NFM110' order by CreatedDate desc];
        //System.assertEquals('1', rowbl[0].ErrorLog__c);
    }
    //促销产品
    static testMethod void coc_romotionPro1() {
        initHpData();
        StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
        List<RecordType> conOrder_Order = [select Id from RecordType where IsActive = true and SobjectType = 'Consumable_order__c' and Name = '01 订单'];
        if (conOrder_Order.size() == 0) {
            return;
        }
 
        List<RecordType> conOrderDetail_Order = [select Id from RecordType where IsActive = true and SobjectType = 'Consumable_orderdetails__c' and Name = '订单'];
        if (conOrderDetail_Order.size() == 0) {
            return;
        }
 
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
        if (rectCo.size() == 0) {
            return;
        }
 
        List<RecordType> rectContract = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '契約'];
        if (rectCo.size() == 0) {
            return;
        }
        Id pricebookId = ControllerUtil.getStandardPricebook().Id;
        // 产品
        Product2 prd1 = new Product2(
            Name='name01',
            IsActive=true,
            Asset_Model_No__c='NFM110Prd1',
            ProductCode = 'NFM110Prd1',
            ProductCode_Ext__c = 'NFM110Prd1',
            Manual_Entry__c=false,
            //SFDA_Status__c='有効',
            Intra_Trade_List_RMB_Date1__c=Date.today().addDays(-1),
            Intra_Trade_List_RMB_Date2__c=Date.today().addDays(-1),
            Intra_Trade_List_RMB_End_Date1__c=Date.today().addDays(1),
            Intra_Trade_List_RMB_End_Date2__c=Date.today().addDays(1),
            Intra_Trade_List_RMB_1__c=100,
            Intra_Trade_List_RMB_2__c=200,
            Intra_Trade_Cost_RMB_Date1__c=Date.today().addDays(-1),
            Intra_Trade_Cost_RMB_Date2__c=Date.today().addDays(-1),
            Intra_Trade_Cost_RMB_End_Date1__c=Date.today().addDays(1),
            Intra_Trade_Cost_RMB_End_Date2__c=Date.today().addDays(1),
            Intra_Trade_Cost_RMB_1__c=10,
            Intra_Trade_Cost_RMB_2__c=20,
            Dealer_special_Object__c = true,
            SFDA_Approbated_Status__c = '不要',
            Product_Status__c = '正常销售'
 
        );
        insert new Product2[] {prd1};
 
        // 価格表エントリを作成する
        PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=prd1.Id);
        entry.UnitPrice = 0;
        entry.IsActive = true;
        entry.UseStandardPrice = false;
        entry.CurrencyIsoCode = 'CNY';
        insert new PricebookEntry[] {entry};
        //经销商、联系人、用户信息
        Account myAccount1 = new Account(name='Testaccount001',
                                        Dealer_discount__c =20,
                                        Ban_On_Use_Date__c = Date.today().addDays(1),
                                        Business_Paper_Expiration_Date__c = Date.today().addDays(1),
                                        Tax_Practice_Expiration_Date__c = Date.today().addDays(1),
                                        Medical_Equipment_Expiration_Date__c = Date.today().addDays(1),
                                        RecordTypeId = rectCo[0].Id);
        insert myAccount1;
        //医疗器械经营许可证
        License_Information__c linc = new License_Information__c( name='Test20181204',
                                                LicenseType__c = '医疗器械经营许可证',
                                                BusinessLicense__c = '20180522',
                                                ValidFrom__c = date.newinstance(2018, 05, 22),
                                                ValidTo__c = date.newinstance(2088, 05, 22),
                                                Scope3__c = '6815;6822;6823;6825',
                                                LicenseAndAccount__c = myAccount1.Id
                                                );
        insert linc;
        Product_Register__c prc = new Product_Register__c(Name = '国械注进20162220210',
                                                MedPrdClass__c = '3',
                                                ValidFrom__c = date.newinstance(2018, 07, 22),
                                                ValidTo__c = date.newinstance(2028, 07, 22),
                                                RegisterNoClass_Old__c = '6815',
                                                RegisterNoClass_New__c = '6815',
                                                RegisterNoStatus__c = '不要'
                                                );
        insert prc;
        //新旧关系对照表
        Product_Register_contrast__c prcc = new Product_Register_contrast__c(
                                                Name = 'Test20181204',
                                                Register_new__c = '314',
                                                Register_old__c = '36815'
                                                );
        insert prcc;
        //产品-产品注册证关系
        Product_Register_Link__c  prlc = new Product_Register_Link__c(
                                                Product2__c = prd1.Id,
                                                Product_Register__c = prc.Id
                                                ); 
        insert prlc;
        Account acc1 = [select Id,Name,Is_Active_Formula__c from Account where Id = : myAccount1.Id];
        System.assertEquals('有效', acc1.Is_Active_Formula__c);
        //经销商有效合同
        Account myAccount2 = new Account(name='Testaccount002',
                                            RecordTypeId = rectContract[0].Id,
                                            Contract_Decide_Start_Date__c = Date.today().addDays(-1),
                                            Contract_Decide_End_Date__c =Date.today().addDays(1),
                                            Contract_Start_Date__c = Date.today().addDays(-1),
                                            Contract_End_Date__c =Date.today().addDays(1),
                                            Agent_Ref__c =myAccount1.Id,
                                            ET_SP_Dealer__c = true,
                                            Business_Assistant__c = UserInfo.getUserId(),
                                            ParentId =myAccount1.Id);
        insert myAccount2;
        Account acc2 = [select Id,Name,Management_Code__c,Is_Active_Formula__c from Account where Id = : myAccount2.Id];
        System.assertEquals('有效', acc2.Is_Active_Formula__c);
 
 
        Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='NFM110Prd1',Product2__c=prd1.id);
        //Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='NFM110Prd2',Product2__c=prd2.id);
        insert new Product2__c[] {pro1};
 
        Consumable_order__c coc = new Consumable_order__c(Name = 'Name001',
                                                            Dealer_Info__c = myAccount1.Id,
                                                            Order_status__c = '批准',
                                                            RecordTypeid = conOrder_Order[0].Id,
                                                            Contract_application_decision__c ='Name001'
                                                            ,SalesManager__c = UserInfo.getUserId(),
                                                            Order_effective_contact__c = myAccount2.Id
                                                            );
        insert coc;
        Consumable_orderdetails__c codc = new Consumable_orderdetails__c(Name='orderdetails001',                                                                            Consumable_order__c = coc.id,
                                                                            Consumable_Product__c =pro1.id,
                                                                            RecordTypeId =conOrderDetail_Order[0].Id,
                                                                            Consumable_count__c = 2,
                                                                            Intra_Trade_List_RMB__c = 100);
        insert codc;
        System.Test.startTest();
        //SendConsumableordertosap.sendSAP(coc.id);
        //System.assertEquals('11111111', SendConsumableordertosap.sendSAP(coc.id));
        //System.Test.stopTest();
        //coc.Name= 'Name0011';
        //update coc;
        Opportunity opp1 = new Opportunity(Name='aiueo10107', StageName='出荷', CurrencyIsoCode='CNY', CloseDate=Date.today(),Purchase_Type__c = 'ET24時間販売'
                             ,Sales_Root__c = '販売店');
        insert opp1;
        Opportunity[] coc12 = [select id,Name,Opportunity_No__c,SAP_Province__c from Opportunity];
        System.assertEquals(1, coc12.size());
        
        NFM110WebService.GeneralData generalData1 = new NFM110WebService.GeneralData();
        NFM110WebService.ProductsDelivery ProductsDelivery = new NFM110WebService.ProductsDelivery();
        
        Datetime nowDT = Datetime.now();
        String nowStr = nowDT.format('yyyyMMddHHmm');
        ProductsDelivery.Monitoring = new NFMUtil.Monitoring();
        ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '01';
 
        ProductsDelivery.GeneralData = new NFM110WebService.GeneralData[] { generalData1 };
        generalData1.DeliveryNote = 'DeliveryNote';
        NFM110WebService.DnInformation dnInfo1 = new NFM110WebService.DnInformation();
        generalData1.DnInformation = new NFM110WebService.DnInformation[] { dnInfo1 };
        generalData1.EndUserNo     = acc2.Management_Code__c;
        generalData1.DepartmentNo  = acc2.Management_Code__c;
        //generalData1.SoNo = coc.Name;
        generalData1.InquiryNo  =   coc12[0].Opportunity_No__c + ',';
        dnInfo1.SorLMark        = 'L';
        dnInfo1.OTCode          = pro1.OT_CODE_Text__c;
        dnInfo1.SerialNoorLotNo = '85K';
        dnInfo1.Barcode         = 'testbarcode001250AAAAA';
        dnInfo1.TracingCode     = 'AAAAA';
 
        
        //System.Test.startTest();
        NFM110WebService.NFM110(ProductsDelivery);
        System.Test.stopTest();
 
        Consumable_order_details2__c[] cod2 = [select id,name,Direct_Arrive_Product__c from Consumable_order_details2__c];
        System.assertEquals(1, cod2.size());
        System.assertEquals(false, cod2[0].Direct_Arrive_Product__c);
        //List<BatchIF_Log__c> rowbl = [Select Id, Log__c, ErrorLog__c from BatchIF_Log__c where RowDataFlg__c = false and Type__c = 'NFM110' order by CreatedDate desc];
        //System.assertEquals('1', rowbl[0].ErrorLog__c);
    }
 
    @isTest
    //直销产品发货
    static void direct_sales() {
        initHpData();
        Product2 prd = new Product2(Name = 'NFM110Prd1', ProductCode = 'NFM110Prd1', ProductCode_Ext__c = 'NFM110Prd1', Manual_Entry__c = false);
        insert prd;
        Product2__c pro1 = new Product2__c(Name='NFM110Prd1',OT_CODE_Text__c='NFM110Prd1',Product2__c=prd.id);
        insert pro1;
        Opportunity opp = new Opportunity(Name='aiueo', StageName='出荷', CloseDate=Date.today(),Sales_Root__c = 'OCM直接販売');
        insert opp;
        Opportunity opps = [select Id, Name, Opportunity_No__c,Sales_Root__c from Opportunity where Id = :opp.Id ];
        System.assertEquals('OCM直接販売', opps.Sales_Root__c);
        Statu_Achievements__c sta = new Statu_Achievements__c(
            Name='test01',
            Opportunity__c = opp.Id,
            DeliveryStatus__c = 'test',
            PaymentRate__c = '1234',
            ContractAmount__c = 0,
            End_User_price__c = 0,
            AssignmentStatus__c = '全部分配',
            Last_week__c = '5 货齐,未付款,无用户合同',
            X2weeks_ago__c = '4 备货中',
            X3Weeks_ago__c = '3 已付款,无用户合同',
            X4weeks_ago__c = '2 待付款',
            X5weeks_ago__c = '1 全没有'
        );
        insert sta;
 
 
        NFM110WebService.GeneralData generalData1 = new NFM110WebService.GeneralData();
        NFM110WebService.ProductsDelivery ProductsDelivery = new NFM110WebService.ProductsDelivery();
        
        Datetime nowDT = Datetime.now();
        String nowStr = nowDT.format('yyyyMMddHHmm');
        ProductsDelivery.Monitoring = new NFMUtil.Monitoring();
        ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '01';
 
        ProductsDelivery.GeneralData = new NFM110WebService.GeneralData[] { generalData1 };
        generalData1.DeliveryNote = 'DeliveryNote';
        NFM110WebService.DnInformation dnInfo1 = new NFM110WebService.DnInformation();
        generalData1.DnInformation = new NFM110WebService.DnInformation[] { dnInfo1 };
        generalData1.EndUserNo     = company.Management_Code_Auto__c;
        generalData1.DepartmentNo  = depart1.Management_Code_Auto__c;
        generalData1.SoNo          = sta.Name;
        generalData1.InquiryNo     = opps.Opportunity_No__c + ',test01';
        generalData1.ReturnMark    = '';
        dnInfo1.SorLMark        = 'L';
        dnInfo1.OTCode          = prd.ProductCode_Ext__c;
        dnInfo1.SerialNoorLotNo = '2577010001675';
        dnInfo1.Barcode = 'Barcodetest250AAAA';
        dnInfo1.TracingCode     = 'AAAAA';
        
        System.Test.startTest();
        NFM110WebService.NFM110(ProductsDelivery);
        System.Test.stopTest();
 
        Asset[] rslts = [select Id, Hospital__c, AccountId, Product2Id, Backorder__c from Asset];
        System.assertEquals(1, rslts.size());
    }
 
    @isTest
    //直销退货发货
    static void direct_return() {
        initHpData();
        Product2 prd = new Product2(Name = 'NFM110Prd1', ProductCode = 'NFM110Prd1', ProductCode_Ext__c = 'NFM110Prd1', Manual_Entry__c = false,Dealer_special_Object__c = true,MDM_Model_No__c = 'NFM110Prd1');
        insert prd;
        Product2__c pro1 = new Product2__c(Name='NFM110Prd1',OT_CODE_Text__c='NFM110Prd1',Product2__c=prd.id);
        insert pro1;
        Product2 prd2 = new Product2(Name = 'NFM110Prd2', ProductCode = 'NFM110Prd2', ProductCode_Ext__c = 'NFM110Prd2', Manual_Entry__c = false,Dealer_special_Object__c = true,MDM_Model_No__c = 'NFM110Prd1');
        insert prd2;
        Product2__c pro2 = new Product2__c(Name='NFM110Prd2',OT_CODE_Text__c='NFM110Prd2',Product2__c=prd2.id);
        insert pro2;
        Asset ast = new Asset(Name='NFM110Ast2', AccountId=depart1.Id, Department_Class__c=section1.Id, Hospital__c=company.Id, Product2Id=prd.Id,
            SerialNumber='2577010001676(BBBBB)', Guarantee_period_for_products__c=Date.today()
        );
        insert ast;
        Opportunity opp = new Opportunity(Name='aiueo', StageName='出荷', CloseDate=Date.today(),Sales_Root__c = 'OCM直接販売');
        insert opp;
        
        Opportunity opps = [select Id, Name, Opportunity_No__c,Sales_Root__c from Opportunity where Id = :opp.Id ];
        System.assertEquals('OCM直接販売', opps.Sales_Root__c);
        Statu_Achievements__c sta = new Statu_Achievements__c(
            Name='test01',
            Opportunity__c = opp.Id,
            DeliveryStatus__c = 'test',
            PaymentRate__c = '1234',
            ContractAmount__c = 0,
            End_User_price__c = 0,
            AssignmentStatus__c = '全部分配',
            Last_week__c = '5 货齐,未付款,无用户合同',
            X2weeks_ago__c = '4 备货中',
            X3Weeks_ago__c = '3 已付款,无用户合同',
            X4weeks_ago__c = '2 待付款',
            X5weeks_ago__c = '1 全没有'
        );
        insert sta;
 
 
        NFM110WebService.GeneralData generalData1 = new NFM110WebService.GeneralData();
        NFM110WebService.ProductsDelivery ProductsDelivery = new NFM110WebService.ProductsDelivery();
        
        Datetime nowDT = Datetime.now();
        String nowStr = nowDT.format('yyyyMMddHHmm');
        ProductsDelivery.Monitoring = new NFMUtil.Monitoring();
        ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '01';
 
        ProductsDelivery.GeneralData = new NFM110WebService.GeneralData[] { generalData1 };
        generalData1.DeliveryNote = 'DeliveryNote';
        NFM110WebService.DnInformation dnInfo1 = new NFM110WebService.DnInformation();
        NFM110WebService.DnInformation dnInfo2 = new NFM110WebService.DnInformation();
        generalData1.DnInformation = new NFM110WebService.DnInformation[] { dnInfo1,dnInfo2 };
        generalData1.EndUserNo     = company.Management_Code_Auto__c;
        generalData1.DepartmentNo  = depart1.Management_Code_Auto__c;
        generalData1.SoNo          = sta.Name;
        generalData1.InquiryNo     = opps.Opportunity_No__c + ',test01';
        generalData1.ReturnMark    = '1';
        dnInfo1.SorLMark        = 'L';
        dnInfo1.OTCode          = prd.ProductCode_Ext__c;
        dnInfo1.SerialNoorLotNo = '2577010001675';
        dnInfo1.Barcode = 'Barcodetest250AAAA';
        dnInfo1.TracingCode     = 'AAAAA';
        dnInfo1.Qty             = '1';
        dnInfo2.SorLMark        = 'L';
        dnInfo2.OTCode          = prd2.ProductCode_Ext__c;
        dnInfo2.SerialNoorLotNo = '2577010001676';
        dnInfo2.Barcode = 'Barcodetest250BBBBB';
        dnInfo2.TracingCode     = 'BBBBB';
        dnInfo2.Qty             = '1';
        
        System.Test.startTest();
        NFM110WebService.NFM110(ProductsDelivery);
        System.Test.stopTest();
 
        Asset[] rslts = [select Id, Hospital__c, AccountId, Product2Id, Backorder__c from Asset];
        System.assertEquals(1, rslts.size());
        Consumable_order_details2__c[] cod2 = [select id,name,Direct_Arrive_Product__c from Consumable_order_details2__c];
        System.assertEquals(2, cod2.size());
    }
}