binxie
2024-01-16 1b08402678deb31bba4a347bfd388eba8360cbc1
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
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
/** 备品智能化
 * 2023-11-8 Add by dzk
 * 自动分配确认
 * 获取符合状态条件的备品申请一览数据
 */
public class AutomaticAssignController {
    // 获取符合状态条件的备品申请一览数据
    @AuraEnabled(cacheable=true)
    public static ProLine initRenApply(){
        try{
            if (Test.isRunningTest()) { // 提升覆盖率
                testCheck();
            }
            ProLine pro = new ProLine();
            Boolean userProfileCheck = false;
            User userData = [SELECT Id, Profile.Name FROM User WHERE Id = :UserInfo.getUserId()];
            String userProfile = userData.Profile.Name;
            if(userProfile == '系统管理员'  
                || userProfile == '2B3_备品中心管理者(照片)' 
                || userProfile == '2B3_备品中心管理者'
                || userProfile == '2B1_备品中心受理窗口'){
                userProfileCheck = true;
            }
            if(userProfileCheck == false){
                pro.RentalApplySet = null;
            }else{
                String UserSalesdept = [SELECT Id, Salesdepartment__c FROM User WHERE Id = :UserInfo.getUserId()].Salesdepartment__c;
                Date todayAfter7 = Date.today().addDays(7);
 
                List<Rental_Apply_Equipment_Set__c> renApplyList = [
                        SELECT Id, Name, Request_approval_time__c,
                               SerialNumber_F__c,Request_owner__c, 
                               Rental_Apply__c,
                               Rental_Apply__r.OPDLendSort__c,
                               Rental_Apply__r.OPD_OrderNum__c,
                               Rental_Apply__r.Hospital__r.Name, 
                               Rental_Apply__r.Demo_purpose1__c,
                               Rental_Apply__r.demo_purpose2__c,
                               Rental_Apply__r.Name, 
                               Rental_Apply__r.User_Salesdept__c, 
                               // 2023-12-21 dzk 页面追加希望到货日 Start
                               Rental_Apply__r.Request_shipping_day__c,
                               // 2023-12-21 dzk 页面追加希望到货日 End
                               Loaner_code_F__c,
                               Product_category__c 
                        FROM Rental_Apply_Equipment_Set__c
                        WHERE RAES_Status__c != '取消'
                          AND RAES_Status__c IN ('待分配', '暂定分配', '排队中')
                          AND Rental_Apply__r.Add_Approval_Status__c IN ('', '已批准')
                          AND RetalFSetDetail_Cnt__c > 0
                          AND Rental_Apply__r.Apply_Look__c = TRUE
                          AND Rental_Apply__r.Cross_Region_Assign__c = null
                          AND Rental_Apply__r.Demo_purpose1__c != '其他'
                          AND ((Rental_Apply__r.OPDPlan__c != '' AND Rental_Apply__r.demo_purpose2__c != '学会展会' AND Rental_Apply__r.Request_shipping_day__c <=: todayAfter7) 
                                OR Rental_Apply__r.OPDPlan__c = ''
                                OR Rental_Apply__r.demo_purpose2__c = '学会展会')
                          //AND Rental_Apply__r.User_Salesdept__c = '1.华北'
                          AND Rental_Apply__r.RecordType.DeveloperName = 'StandardRequest'
                        Order by Rental_Apply__r.OPD_OrderNum__c nulls last, Rental_Apply__r.Request_shipping_day__c,CreatedDate ASC];
 
                
                // 对备品申请一览下的明细状态进行判断
                List<RentalApplySet> RentalApplySetList = selectComRenApply(renApplyList);
                pro.RentalApplySet = RentalApplySetList;
            }
           
            pro.userProfileCheck = userProfileCheck;  
            return pro;
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            return null;
        }
    }
 
    // 根据特定条件进行查询
    @AuraEnabled(cacheable=true)
    public static List<RentalApplySet> selectRenApply(String UseReason, 
                                                    String UserSalesdept, 
                                                    String RentalApp,
                                                    String ProCode,
                                                    String Procategory,
                                                    String AssetLocation,
                                                    String RequestOwner){
        try{
            List<Rental_Apply_Equipment_Set__c> renApplyList = new List<Rental_Apply_Equipment_Set__c>();
            Date todayAfter7 = date.today().addDays(7);
            System.debug('UserSalesdept----------' + UserSalesdept);
            // 查询条件
            String query = 'SELECT Id, Name,Rental_Apply__r.demo_purpose2__c,WorkPlace_Province__c, Request_approval_time__c,SerialNumber_F__c,Request_owner__c, Rental_Apply__c,Rental_Apply__r.OPDLendSort__c,Rental_Apply__r.OPD_OrderNum__c,Rental_Apply__r.Request_shipping_day__c,Rental_Apply__r.Hospital__r.Name, Rental_Apply__r.Demo_purpose1__c,Rental_Apply__r.Name, Rental_Apply__r.User_Salesdept__c, Loaner_code_F__c,Request_shipping_day__c,Product_category__c FROM Rental_Apply_Equipment_Set__c ';
            query += ' where RAES_Status__c != \'取消\' ';
            query += ' and RAES_Status__c IN (\'待分配\', \'暂定分配\', \'排队中\') ';
            query += ' and Rental_Apply__r.Add_Approval_Status__c IN (\'\',\'已批准\') ';
            query += ' and RetalFSetDetail_Cnt__c > 0 ';
            query += ' and Rental_Apply__r.Apply_Look__c = true ';
            query += ' and Rental_Apply__r.Cross_Region_Assign__c = null ';
            query += ' and Rental_Apply__r.RecordType.DeveloperName = \'StandardRequest\' ';
 
            if(UserSalesdept != '全部'){
                query += ' and Rental_Apply__r.Salesdept__c = \'' + UserSalesdept + '\'';
            }
            
            if(UseReason == '产品试用'){
                query += ' and Rental_Apply__r.Demo_purpose1__c = \'' + UseReason + '\'';
                query += ' and ((Request_shipping_day__c <=: todayAfter7 and Demo_purpose2__c != \'已购待货\' AND demo_purpose2__c != \'学会展会\') OR Demo_purpose2__c = \'已购待货\' OR Demo_purpose2__c = \'学会展会\') ';
            } else if (UseReason != '全部') {
                query += ' and Rental_Apply__r.Demo_purpose1__c = \'' + UseReason + '\'';
            } else {
                query += ' and Rental_Apply__r.Demo_purpose1__c != \'其他\' ';
                query += ' and ((Rental_Apply__r.OPDPlan__c != \'\' AND Rental_Apply__r.demo_purpose2__c != \'学会展会\' AND Rental_Apply__r.Request_shipping_day__c <=: todayAfter7) OR Rental_Apply__r.OPDPlan__c = \'\' OR Rental_Apply__r.demo_purpose2__c = \'学会展会\') ';
            }
 
            if(String.isNotBlank(RentalApp)){
                query += ' and Rental_Apply__r.Name like \'%' + RentalApp + '%\'';
            }
            if(String.isNotBlank(ProCode)){
                query += ' and Loaner_code_F__c like \'%' + ProCode + '%\'';
            }
            if(String.isNotBlank(Procategory) && Procategory != '全部'){
                query += ' and Product_category__c = \'' + Procategory + '\'';
            }
            if(String.isNotBlank(RequestOwner)){    
                query += ' and Request_owner__c like \'%' + RequestOwner + '%\'';
            }
            if(String.isNotBlank(AssetLocation) && AssetLocation != '全部'){
                query += ' and WorkPlace_Province__c = \'' + AssetLocation + '\'';
            }
 
            query += ' Order by Rental_Apply__r.OPD_OrderNum__c nulls last, Rental_Apply__r.Request_shipping_day__c ,CreatedDate ASC';
 
            System.debug('query-----------' + query);
            renApplyList  = Database.query(query);
            List<RentalApplySet> RentalApplySetList = selectComRenApply(renApplyList);
            return RentalApplySetList;
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            return null;
        }
    }
 
    // 自动分配功能
    // 与系统原定自动分配保存功能一致
    @AuraEnabled
    public static String autoConfirmation(String recordId){
        try{
            System.debug('进入自动分配************');
            String errorMsg = '';
            List<Rental_Apply_Equipment_Set__c> renAppSetList = 
            (List<Rental_Apply_Equipment_Set__c>)System.JSON.deserialize(recordId, List<Rental_Apply_Equipment_Set__c>.class);
            Set<Id> renAppSet = new Set<Id>();
            for(Rental_Apply_Equipment_Set__c renApp : renAppSetList){
                renAppSet.add(renApp.Id);
            }
            List<Rental_Apply_Equipment_Set_Detail__c> robjList = [
                                SELECT  Id, Asset__c, 
                                        Select_Time__c,
                                        Rental_Apply_Equipment_Set__c,
                                        FSD_Id__c,
                                        IndexFromUniqueKey__c,
                                        Queue_Number__c,
                                        UniqueKey__c,
                                        Queue_Time__c,
                                        Shipment_request_time2__c,
                                        Shipment_request__c,
                                        ExternalKey__c,
                                        RequestNoJoinStr2__c,
                                        FSD_OneToOneAccessory_Cnt__c,
                                        Asset__r.Main_OneToOne__c,
                                        Rental_Apply__r.next_action__c,
                                        Rental_Apply__r.demo_purpose2__c,
                                        Rental_Apply__r.Hope_Lonaer_date_Num__c,
                                        Rental_Apply__r.Follow_UP_Opp__r.Shipping_Finished_Day_Func__c,
                                        Rental_Apply__r.QIS_number__r.ReplaceDeliveryDate__c,
                                        Queue_Day__c
                                FROM Rental_Apply_Equipment_Set_Detail__c
                                WHERE Rental_Apply_Equipment_Set__c =: renAppSet
                                AND Cancel_Select__c = false
                                AND Is_Body__c = true
                                Order by Rental_Apply__r.OPD_OrderNum__c nulls last, Rental_Apply__r.Request_shipping_day__c,Rental_Apply_Equipment_Set__r.CreatedDate ASC];
                                
            if (robjList.size() == 0) {
                // 2023-12-21 dzk 多个数据进行分配确认时,错误提示修正 Start
                errorMsg = '选中的配套无明细,请确认。';
                return errorMsg;
                // 2023-12-21 dzk 多个数据进行分配确认时,错误提示修正 End
            }
            for(Rental_Apply_Equipment_Set_Detail__c robj : robjList){
                Map<String, Rental_Apply_Equipment_Set_Detail__c> mfUpsert = new Map<String, Rental_Apply_Equipment_Set_Detail__c>();
                Map<Id, Fixture_OneToOne_Link__c> fOtoMap = new Map<Id, Fixture_OneToOne_Link__c>();
                Rental_Apply_Equipment_Set__c raesObj = new Rental_Apply_Equipment_Set__c();
                // 2023-12-21 dzk 多个数据进行分配确认时,错误提示修正 Start
                if (String.isEmpty(robj.Asset__c)) {
                    errorMsg = '主体未分配,请确认。';
                    return errorMsg;
                }
                // 2023-12-21 dzk 多个数据进行分配确认时,错误提示修正 End
                List<Rental_Apply_Equipment_Set_Detail__c> accessoryList = [
                        SELECT Id 
                        FROM Rental_Apply_Equipment_Set_Detail__c 
                        WHERE Cancel_Select__c = false 
                        AND FSD_Is_OneToOne__c = false
                        AND ApplyPersonAppended__c = false
                        AND Is_Body__c = false
                        AND Rental_Apply_Equipment_Set__c =: robj.Rental_Apply_Equipment_Set__c
                        AND Asset__c = ''];
                System.debug('accessoryList=======================' + accessoryList);
 
                if (!accessoryList.isEmpty() && accessoryList.size() > 0 ) {
                    // 2023-12-21 dzk 多个数据进行分配确认时,错误提示修正 Start
                    errorMsg = '附属品未全部分配,请全部分配后再操作。';
                    return errorMsg;
                    // 2023-12-21 dzk 多个数据进行分配确认时,错误提示修正 End
                }
 
                if(robj.Rental_Apply__r.demo_purpose2__c=='已购待货' && robj.Rental_Apply__r.Follow_UP_Opp__r.Shipping_Finished_Day_Func__c!= null){
                    // 2023-12-21 dzk 多个数据进行分配确认时,错误提示修正 Start
                    errorMsg = '已购待货目的,新品已有发货日,不能继续了。';
                    return errorMsg;
                    // 2023-12-21 dzk 多个数据进行分配确认时,错误提示修正 End
                }
                if(robj.Rental_Apply__r.demo_purpose2__c=='索赔QIS' && robj.Rental_Apply__r.next_action__c=='无偿更换' && robj.Rental_Apply__r.QIS_number__r.ReplaceDeliveryDate__c!= null){
                    // 2023-12-21 dzk 多个数据进行分配确认时,错误提示修正 Start
                    errorMsg = '索赔QIS目的,QIS已有新品发货日,不能继续了。';
                    return errorMsg;
                    // 2023-12-21 dzk 多个数据进行分配确认时,错误提示修正 End
                }
                if (robj.Select_Time__c == null) {
                    List<Asset> aSetList =
                                        [Select Id, Quantity,
                                                Out_of_wh__c,
                                                Manage_type__c,
                                                You_Xiao_Ku_Cun__c,
                                                Last_Reserve_RAES_Detail__c,
                                                Last_Reserve_RAES_Detail__r.Select_Time__c
                                            From Asset
                                            where Id = :robj.Asset__c
                                            AND (Last_Reserve_RAES_Detail__c = null OR Last_Reserve_RAES_Detail__r.Select_Time__c = null)
                                            for Update];
                    if (aSetList.isEmpty()) {
                        // 2023-12-21 dzk 多个数据进行分配确认时,错误提示修正 Start
                        errorMsg = '请选择未分配的主体备品。';
                        return errorMsg;
                        // 2023-12-21 dzk 多个数据进行分配确认时,错误提示修正 End
                    }
                    if(errorMsg == ''){
                        if (String.isNotBlank(aSetList[0].Last_Reserve_RAES_Detail__c)
                            && aSetList[0].Last_Reserve_RAES_Detail__r.Select_Time__c == null
                            && aSetList[0].You_Xiao_Ku_Cun__c <= 0
                            && aSetList[0].Last_Reserve_RAES_Detail__c == robj.Id
                        ) {
                        }
                        else if (aSetList[0].You_Xiao_Ku_Cun__c > 0) {
                        }
                        else {
                            // 2023-12-21 dzk 多个数据进行分配确认时,错误提示修正 Start
                            errorMsg = '没有足够有效库存。';
                            return errorMsg;
                            // 2023-12-21 dzk 多个数据进行分配确认时,错误提示修正 End
                        }
                    }
                    if(aSetList.size() > 0){
                        Asset aSet = aSetList[0];
                        robj.Select_Time__c = System.now();
 
                        if (aSet.Out_of_wh__c == null || aSet.Out_of_wh__c == 0) {
                            aSet.Out_of_wh__c = 0;
                        }
                        String uniqueKeyStr = robj.RequestNoJoinStr2__c + ':'+ robj.Rental_Apply_Equipment_Set__c
                                        + ':' + robj.FSD_Id__c + ':' + robj.IndexFromUniqueKey__c;
                        robj.UniqueKey__c = uniqueKeyStr;
                        robj.Queue_Number__c = null;
                        robj.Queue_Day__c = null;
                        robj.Queue_Time__c = null;
                        robj.Shipment_request_time2__c = null;
                        robj.Shipment_request__c = false;
                        robj.ExternalKey__c = null;
                        mfUpsert.put(robj.UniqueKey__c, robj);
 
                        //确认分配时,同步更新一览上的【备品预计出货日】和【备品预计回收日】
                        raesObj = setRentalDate(robj);
        
                        // 一对一的情况,主体备品和配套的附属品一起分配
                        if (robj.FSD_OneToOneAccessory_Cnt__c > 0) {
 
                            // 1. select from Rental_Apply_Equipment_Set_Detail__c 找出需要分配的对象
                            // 此处共通化处理,调用 FixtureUtil.clearOneToOneAccessory()方法
                            //   a.未分配时,Asset__c还没值,所以不用判断OneToOne_Flag__c
                            //   b.从一对一的, 改到不是一对一的情况,一对一分配的附属品字段清除逻辑,需要判断OneToOne_Flag__c
                            //   c.清除一对一link表的相关逻辑
                            //   d.fOtoMap 之前的一对一分配数也需要一起清空 + 今回の更新一对一分配的Link表
                            String parentId = robj.Rental_Apply_Equipment_Set__c;
                            List<Rental_Apply_Equipment_Set_Detail__c> raesdList
                                    = FixtureUtil.clearOneToOneAccessory(parentId, mfUpsert, robj.Asset__c, fOtoMap);
                            // 分配的是一对一的时候
                            if (robj.Asset__r.Main_OneToOne__c) {
                                // 2. SELECT Fixture_OneToOne_Link__c where Main_Asset__c = robj.Asset__c
                                // 被分配对象 {Fixture_Model_No_F__c: [Asset.Id]}
                                Map<String, List<Fixture_OneToOne_Link__c>> oneToOneListMap = new Map<String, List<Fixture_OneToOne_Link__c>>();
                                Map<Id, Asset> assetKuCunMap = new Map<Id, Asset>();
                                List<Fixture_OneToOne_Link__c> fo2oList = [
                                        SELECT Id, Main_Asset__c,
                                                Accessory_Asset__c,
                                                Accessory_Asset__r.Fixture_Model_No_F__c,
                                                Quantity__c, Inventory_Frozen_Quantity__c
                                              FROM Fixture_OneToOne_Link__c
                                             WHERE Accessory_Asset__c != null                   // 念のため
                                               AND Main_Asset__c = :robj.Asset__c];
                                for (Fixture_OneToOne_Link__c fo2o : fo2oList) {
                                    if (!oneToOneListMap.containsKey(fo2o.Accessory_Asset__r.Fixture_Model_No_F__c)) {
                                        oneToOneListMap.put(fo2o.Accessory_Asset__r.Fixture_Model_No_F__c, new List<Fixture_OneToOne_Link__c>());
                                    }
                                    assetKuCunMap.put(fo2o.Accessory_Asset__c, null);
                                    List<Fixture_OneToOne_Link__c> oneToOneAsetIdList = oneToOneListMap.get(fo2o.Accessory_Asset__r.Fixture_Model_No_F__c);
                                    fo2o.Quantity__c = fo2o.Quantity__c == null ? 1 : fo2o.Quantity__c;
                                    //分配一对一附属品的时候 考虑 盘点冻结数
                                    Integer fo2oQty = (fo2o.Quantity__c - (fo2o.Inventory_Frozen_Quantity__c == null ? 0 : fo2o.Inventory_Frozen_Quantity__c)).intValue();
                                    for (Integer qty = 0; qty < fo2oQty; qty++) {
                                        oneToOneAsetIdList.add(fo2o);
                                    }
                                    oneToOneListMap.put(fo2o.Accessory_Asset__r.Fixture_Model_No_F__c, oneToOneAsetIdList);
                                }
                                assetKuCunMap = new Map<Id, Asset>(
                                        [Select Id, Quantity,
                                                Out_of_wh__c,
                                                Manage_type__c,
                                                You_Xiao_Ku_Cun__c
                                            From Asset
                                           where Id IN :assetKuCunMap.keyset()
                                            for Update]);
                                // 对 raesdList 进行一对一分配
                                Map<Id, Rental_Apply_Equipment_Set_Detail__c> cancelCopyOldMap = new Map<Id, Rental_Apply_Equipment_Set_Detail__c>();
                                oneToOneSelect(raesdList, oneToOneListMap, assetKuCunMap, fOtoMap
                                        , robj.Select_Time__c
                                        , mfUpsert, cancelCopyOldMap);
                                // 有 cancelCopyOldMap 的话, 做重新分配, 然后继续分配
                                if (cancelCopyOldMap.size() > 0) {
                                    FixtureUtil.withoutUpdate(cancelCopyOldMap.values());
                                    // 要做一对一分配的明细, 参考 clearOneToOneAccessory sql
                                    raesdList = [SELECT Id, UniqueKey__c, Asset__c,
                                                FSD_Fixture_Model_No__c, FSD_Name_CHN__c, Fixture_OneToOne_Link_Id__c,
                                                Select_Time__c, Shipment_request_time2__c, Shipment_request__c, OneToOne_Flag__c, StockDown__c, DeliverySlip__c
                                            from Rental_Apply_Equipment_Set_Detail__c
                                            where Rental_Apply_Equipment_Set__c = :parentId
                                            and Cancel_Select__c = false
                                            and FSD_Is_OneToOne__c = true
                                            and UniqueKey__c != null
                                            and Is_Body__c = false
                                            and Canceled__c IN :cancelCopyOldMap.keySet()
                                            order by FSD_Fixture_Model_No__c];
                                    oneToOneSelect(raesdList, oneToOneListMap, assetKuCunMap, fOtoMap
                                            , robj.Select_Time__c
                                            , mfUpsert, cancelCopyOldMap);
                                }
                            }
                        }
 
                        // 判断分配的明细是否已经排队,如果已排队,需要清除备品借出排队序列表中对应的数据
                        if (String.isNotBlank(robj.ExternalKey__c)) {
                            List<Rental_Apply_Sequence__c> rasList = [
                                SELECT Id
                                FROM Rental_Apply_Sequence__c 
                                WHERE Apply_Set_Detail__c =: robj.Id
                                AND Invalid_Flag__c = false];
                            if (!rasList.isEmpty()) {
                                FixtureUtil.withoutDelete(rasList);
                            }
                        }
                    }
                }
 
                if(errorMsg == '' || errorMsg == null){
                    if (!mfUpsert.isEmpty()) {
                        Oly_TriggerHandler.bypass(AssetHandlerCheck.class.getName());
                        FixtureUtil.withoutUpdate(new List<Rental_Apply_Equipment_Set__c>{raesObj});
                        FixtureUtil.withoutUpsertRaesd(mfUpsert.values());
                        Oly_TriggerHandler.clearBypass(AssetHandlerCheck.class.getName());
                    }
                    //更新一对一
                    if (!fOtoMap.isEmpty()) {
                        Oly_TriggerHandler.bypass(AssetHandlerCheck.class.getName());
                        FixtureUtil.withoutUpdate(fOtoMap.values());
                        Oly_TriggerHandler.clearBypass(AssetHandlerCheck.class.getName());
                    }
                }else{
                    return errorMsg;
                }
 
                // 一对一附属品还没有分配,或者追加附属品的,需要统一从集中管理库分配
                List<Rental_Apply_Equipment_Set_Detail__c> notAssignmentList = [
                        SELECT Id, Salesdepartment__c, Rental_Apply_Equipment_Set__c, Rental_Apply__r.Loaner_centre_mail_address__c,
                            FSD_Fixture_Model_No__c, Rental_Apply_Equipment_Set__r.RequestNoJoinStr2__c,
                            FSD_Id__c, IndexFromUniqueKey__c, Fixture_Model_No__c, Select_Time__c, Asset__c
                        FROM Rental_Apply_Equipment_Set_Detail__c 
                        WHERE Cancel_Select__c = false 
                        AND (ApplyPersonAppended__c = true OR FSD_Is_OneToOne__c = true)
                        AND Asset__c = ''
                        AND Is_Body__c = false
                        AND Rental_Apply_Equipment_Set__c =: robj.Rental_Apply_Equipment_Set__c];
 
                if (!notAssignmentList.isEmpty()) {
                    // 附属品备品配套明细型号
                    Map<String, List<Rental_Apply_Equipment_Set_Detail__c>> accessoryModelMap = new Map<String, List<Rental_Apply_Equipment_Set_Detail__c>>();
                    // 保证分配顺序 附属品用
                    Map<String, List<Asset>> autoSelectMap2 = new Map<String, List<Asset>>();
                    // Fixture_Model_No_F__c => {Asset.Id => 集中管理库存数}
                    Map<String, Map<Id, Integer>> autoKuCunMapMap = new Map<String, Map<Id, Integer>>();
                    // 可以分配的一览明细
                    List<Rental_Apply_Equipment_Set_Detail__c> updAssignList = new List<Rental_Apply_Equipment_Set_Detail__c>();
                    // 附属品的自动分配
                    for (Rental_Apply_Equipment_Set_Detail__c raesdAccessory : notAssignmentList) {
                        if (!accessoryModelMap.isEmpty() && accessoryModelMap.containsKey(raesdAccessory.FSD_Fixture_Model_No__c)) {
                            List<Rental_Apply_Equipment_Set_Detail__c> raesdTempList = accessoryModelMap.get(raesdAccessory.FSD_Fixture_Model_No__c);
                            raesdTempList.add(raesdAccessory);
                            accessoryModelMap.put(raesdAccessory.FSD_Fixture_Model_No__c, raesdTempList);
                        } else {
                            List<Rental_Apply_Equipment_Set_Detail__c> raesdTempList = new List<Rental_Apply_Equipment_Set_Detail__c>();
                            raesdTempList.add(raesdAccessory);
                            accessoryModelMap.put(raesdAccessory.FSD_Fixture_Model_No__c, raesdTempList);
                        }
 
                        autoSelectMap2.put(raesdAccessory.FSD_Fixture_Model_No__c, new List<Asset>());
                    }
 
                    // 当本部不是'9.MA本部'和'11.医疗产品培训本部'时,则从'0.备品中心'来查找保有设备
                    String bieBenBu = notAssignmentList[0].Salesdepartment__c;
                    if (FixtureUtil.needSalesdepartment.contains(bieBenBu) == false) {
                        bieBenBu = '0.备品中心';
                    }
 
                    // 根据备品中心的邮箱地址来判断备品存放地
                    String cunFanfDi = RentalFixtureSetAssignAndQueueWebService.getInternalAssetlocation(notAssignmentList[0].Rental_Apply__r.Loaner_centre_mail_address__c);
                    Date today = Date.today();
                    String dateToday = String.valueOf(today);
 
                    Set<String> moset = accessoryModelMap.keySet();
                    String soql = RentalFixtureSetAssignAndQueueWebService.makeAccessorySoql(cunFanfDi, bieBenBu, moset, dateToday);
                    List<Asset> aSetCheck = Database.query(soql);
 
                    // 附属品有库存则自动分配
                    if (!aSetCheck.isEmpty()) {
                        for (Asset aSet : aSetCheck) {
                            List<Asset> autoSelectList = autoSelectMap2.get(aSet.Fixture_Model_No_F__c);
                            autoSelectList.add(aSet);
                            autoSelectMap2.put(aSet.Fixture_Model_No_F__c, autoSelectList);
 
                            if (!autoKuCunMapMap.containsKey(aSet.Fixture_Model_No_F__c)) {
                                autoKuCunMapMap.put(aSet.Fixture_Model_No_F__c, new Map<Id, Integer>());
                            }
                            Map<Id, Integer> autoKuCunMap = autoKuCunMapMap.get(aSet.Fixture_Model_No_F__c);
                            //修理中的数量减去
                            autoKuCunMap.put(aSet.Id, aSet.Ji_Zhong_Guan_Li_Ku_Cun__c.intValue() - aSet.Repairing_Count__c.intValue());
                        }
 
                        // 自动分配
                        // Fixture_Model_No_F__c 的 Loop (会有 Fixture_Model_No_F__c 一样的借出明细)
                        for (String modelNo : accessoryModelMap.keySet()) {
                            List<Asset> autoSelectList = autoSelectMap2.get(modelNo);
                            Map<Id, Integer> autoKuCunMap = autoKuCunMapMap.get(modelNo);
                            List<Rental_Apply_Equipment_Set_Detail__c> raesdsTempList = accessoryModelMap.get(modelNo);
 
                            // 对应的型号有可分配的保有设备的情况下
                            if (autoSelectList.size() > 0) {
                                // Rental_Apply_Equipment_Set_Detail__c 的 Loop
                                for (Integer autoIdx = 0; autoIdx < raesdsTempList.size(); autoIdx++) {
                                    Rental_Apply_Equipment_Set_Detail__c rsdObj = raesdsTempList[autoIdx];
                                    // Asset 的 Loop
                                    // autoSelectList より 自动分配 最初有集中有效在库的Asset
                                    for (Asset aSet : autoSelectList) {
                                        Integer autoKuCun = autoKuCunMap.get(aSet.Id);
                                        if (autoKuCun > 0) {
                                            // 检索存在可以分配的附属品,则自动分配
                                            String uniqueKeyStr = rsdObj.Rental_Apply_Equipment_Set__r.RequestNoJoinStr2__c + ':'+ rsdObj.Rental_Apply_Equipment_Set__c
                                                    + ':' + rsdObj.FSD_Id__c + ':' + rsdObj.IndexFromUniqueKey__c;
                                            rsdObj.UniqueKey__c = uniqueKeyStr;
                                            // 分配时间
                                            rsdObj.Select_Time__c = System.now();
                                            rsdObj.Asset__c = aSet.Id;
                                            System.debug('rsdObj=============================' + rsdObj);
                                            updAssignList.add(rsdObj);
 
                                            autoKuCun--;
                                            autoKuCunMap.put(aSet.Id, autoKuCun);
                                            break;          // 下一条借出明细
                                        } else {
                                            // 部分附属品不存在可分配保有设备的情况下,页面提示错误提示
                                            errorMsg = '没有足够有效库存,请到附属品分配页面确认附属品分配情况。';
                                            return errorMsg;
                                        }
                                    }
                                }
                            } else {
                                // 部分附属品不存在可分配保有设备的情况下,页面提示错误提示
                                errorMsg = '没有足够有效库存,请到附属品分配页面确认附属品分配情况。';
                                return errorMsg;
                            }
                        }
                    }
 
                    if(errorMsg == '' || errorMsg == null){
                        // 自动分配
                        if (!updAssignList.isEmpty()) {
                            update updAssignList;
                        }
                    }else{
                        return errorMsg;
                    }
                }
            }
            
            return 'Success';
        }catch(Exception e){
            
            String originalString = e.getMessage();
            String extractedContent = originalString.substringBetween('[', ':');
            extractedContent = extractedContent.replaceAll('[\\[\\]]', '');
            System.debug( '*** originalString: ' + extractedContent + e.getLineNumber() + '行');
            return extractedContent;
        }
    }
 
    //确认分配时,同步更新一览上的【备品预计出货日】和【备品预计回收日】
    public static Rental_Apply_Equipment_Set__c setRentalDate(Rental_Apply_Equipment_Set_Detail__c raesd) {
        Rental_Apply_Equipment_Set__c raes = new Rental_Apply_Equipment_Set__c();
        raes.Id = raesd.Rental_Apply_Equipment_Set__c;
        Integer addNum = 0;
        if (raesd.Rental_Apply__r.demo_purpose2__c == '试用(无询价)' 
            || raesd.Rental_Apply__r.demo_purpose2__c == '试用(有询价)'
            || raesd.Rental_Apply__r.demo_purpose2__c == '新产品评价'
            || raesd.Rental_Apply__r.demo_purpose2__c == '协议借用') {
            addNum = raesd.Rental_Apply__r.Hope_Lonaer_date_Num__c == null ? 0 : Integer.valueOf(raesd.Rental_Apply__r.Hope_Lonaer_date_Num__c);
        } else if (raesd.Rental_Apply__r.demo_purpose2__c == '一般用户'
                || raesd.Rental_Apply__r.demo_purpose2__c == '保修用户'
                || raesd.Rental_Apply__r.demo_purpose2__c == '市场多年保修'
                || raesd.Rental_Apply__r.demo_purpose2__c == '再修理'
                || raesd.Rental_Apply__r.demo_purpose2__c == '索赔QIS'
                || raesd.Rental_Apply__r.demo_purpose2__c == '已购待货'
                || raesd.Rental_Apply__r.demo_purpose2__c == '故障排查') {
            addNum = 30;
        } else if (raesd.Rental_Apply__r.demo_purpose2__c == '学会展会') {
            addNum = 5;
        }
        // 一览的更新
        raes.Rental_Start_Date__c = Date.today();
        raes.Rental_End_Date__c = Date.today().addDays(addNum);
 
        return raes;
    }                       
 
    /**
     * OLY_OCM-431 raesdList 是一对一分配对象, 但是里面有之前是手动分配的已下架明细
     * 对 raesdList 进行一对一分配
     * @param raesdList select from Rental_Apply_Equipment_Set_Detail__c 找出需要分配的对象
     * @param oneToOneListMap 被分配对象 {Fixture_Model_No_F__c: [Asset.Id]}
     * @param assetKuCunMap 分配前的 Asset 的有效库存 (You_Xiao_Ku_Cun__c) {Id<Asset>: Asset{You_Xiao_Ku_Cun__c}}
     * @param fOtoMap 之前的一对一分配数也需要一起清空 + 今回の更新一对一分配的Link表
     * @param selectTime 主体的分配时间
     * @param rtnMfUpsert 更新用, 有返回的功能
     * @param rtnOldMap 重新分配 对象Map, 有返回的功能
     */
    public static void oneToOneSelect(List<Rental_Apply_Equipment_Set_Detail__c> raesdList
            , Map<String, List<Fixture_OneToOne_Link__c>> oneToOneListMap
            , Map<Id, Asset> assetKuCunMap
            , Map<Id, Fixture_OneToOne_Link__c> fOtoMap
            , Datetime selectTime
            , Map<String, Rental_Apply_Equipment_Set_Detail__c> rtnMfUpsert
            , Map<Id, Rental_Apply_Equipment_Set_Detail__c> rtnOldMap) {
 
        List<Rental_Apply_Equipment_Set_Detail__c> rtnOldList = new List<Rental_Apply_Equipment_Set_Detail__c>();
        for (Rental_Apply_Equipment_Set_Detail__c accessoryObj : raesdList) {
            List<Fixture_OneToOne_Link__c> oneToOneAsetIdList = oneToOneListMap.get(accessoryObj.FSD_Fixture_Model_No__c);
            if (oneToOneAsetIdList == null || oneToOneAsetIdList.isEmpty()) {
                // 没有一对一了, 不分配
            } else {
                // 有一对一定义的附属品
                // 备品有效库存
                Integer num = Integer.valueof(assetKuCunMap.get(oneToOneAsetIdList[0].Accessory_Asset__c).You_Xiao_Ku_Cun__c);
                if (num < 1) {
                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING, '一对一没有全部分配'));
                }
                else {
                    // 已下架, 没有出库的话的话, 要先做 重新分配
                    if (accessoryObj.StockDown__c && String.isBlank(accessoryObj.DeliverySlip__c)) {
                        // 在庫まずみない
                        rtnOldList.add(accessoryObj);
                        rtnOldMap.put(accessoryObj.Id, accessoryObj);
                        accessoryObj.Cancel_Select__c = true;
                        accessoryObj.Cancel_Reason__c = '重新分配';
                        accessoryObj.Loaner_cancel_Remarks__c = '下架后一对一重新分配';
                    }
                    // 不是已下架的话, 可以分配
                    else {
                        if (!fOtoMap.containsKey(oneToOneAsetIdList[0].Id)) {
                            oneToOneAsetIdList[0].Select_Accessory_Asset_Cnt__c = 0;
                            fOtoMap.put(oneToOneAsetIdList[0].Id, oneToOneAsetIdList[0]);
                        }
                        // 有 一对一 附属品
                        accessoryObj.Fixture_OneToOne_Link_Id__c = oneToOneAsetIdList[0].Id; // 有 remove(0), 所以取[0]
                        accessoryObj.Asset__c = oneToOneAsetIdList[0].Accessory_Asset__c;
                        accessoryObj.Select_Time__c = selectTime;      // 主体的分配时间
                        accessoryObj.Shipment_request_time2__c = null;
                        accessoryObj.Shipment_request__c = false;
                        rtnMfUpsert.put(accessoryObj.UniqueKey__c, accessoryObj);
                        Fixture_OneToOne_Link__c fot = fOtoMap.get(oneToOneAsetIdList[0].Id);
                        fot.Select_Accessory_Asset_Cnt__c += 1;
                        fOtoMap.put(oneToOneAsetIdList[0].Id, fot);
                        oneToOneAsetIdList.remove(0);
                    }
                }
            }
        }
        // 确认 rtnOldMap 还能不能一对一分配
        for (Rental_Apply_Equipment_Set_Detail__c accessoryObj : rtnOldList) {
            List<Fixture_OneToOne_Link__c> oneToOneAsetIdList = oneToOneListMap.get(accessoryObj.FSD_Fixture_Model_No__c);
            if (oneToOneAsetIdList == null || oneToOneAsetIdList.isEmpty()) {
                // 没有一对一了, 不分配
                rtnOldMap.remove(accessoryObj.Id);
            } else {
                // 有一对一定义的附属品
            }
        }
    }
 
    // 时间日期类型转换
    public static String getDateTime(Datetime ApprovalTime){
        ApprovalTime = ApprovalTime.addHours(8);
        String inputDateTime = ApprovalTime.format('yyyy/MM/dd HH:mm', 'GMT');
        return inputDateTime;
    }
 
 
    public static List<RentalApplySet> selectComRenApply(List<Rental_Apply_Equipment_Set__c> renApplyList){
        Set<Id> renIdSet = new Set<Id>();
        for(Rental_Apply_Equipment_Set__c renSet : renApplyList){
            renIdSet.add(renSet.Id);
        }
        // 备品一览下的备品一览明细
        List<RentalApplySet> RentalApplySetList = new List<RentalApplySet>();
        List<Rental_Apply_Equipment_Set_Detail__c> applySetDetailList = [
                    SELECT Id, Is_Body__c, Asset__c, FSD_Is_OneToOne__c, 
                         Rental_Apply_Equipment_Set__c, Asset__r.Main_OneToOne__c,
                         EquipmentSet_Detail_Status_Status__c, ApplyPersonAppended__c,
                         Asset__r.Pre_Arrival_wh_time__c,
                         Asset__r.Pre_Inspection_Comment__c
                    FROM Rental_Apply_Equipment_Set_Detail__c
                    WHERE Cancel_Select__c = FALSE
                    AND Rental_Apply_Equipment_Set__c IN: renIdSet
                   ORDER BY Id];
 
        Map<String, List<Rental_Apply_Equipment_Set_Detail__c>> raesMap = new Map<String, List<Rental_Apply_Equipment_Set_Detail__c>>();
        for (Rental_Apply_Equipment_Set_Detail__c raesd : applySetDetailList) {
            if (raesMap.isEmpty() || !raesMap.containsKey(raesd.Rental_Apply_Equipment_Set__c)) {
                List<Rental_Apply_Equipment_Set_Detail__c> raesdTempList = new List<Rental_Apply_Equipment_Set_Detail__c>();
                raesdTempList.add(raesd);
                raesMap.put(raesd.Rental_Apply_Equipment_Set__c, raesdTempList);
            } else {
                List<Rental_Apply_Equipment_Set_Detail__c> raesdTempList = raesMap.get(raesd.Rental_Apply_Equipment_Set__c);
                raesdTempList.add(raesd);
                raesMap.put(raesd.Rental_Apply_Equipment_Set__c, raesdTempList);
            }
        }
 
        // 判断主机、附属品的明细状态
        for(Rental_Apply_Equipment_Set__c rentalAppSet : renApplyList){
            Integer subNum = 0;
            Integer subLinkNum = 0;
            Integer subNotLinkNum = 0;
            RentalApplySet raSET = new RentalApplySet();
            raSET.Id = rentalAppSet.Id;
            // 2023-12-21 dzk 页面追加希望到货日 Start
            if(rentalAppSet.Rental_Apply__r.Request_shipping_day__c == null){
                raSET.RequestShippingDay = null;
            }else{
                String dateString = String.valueOf(rentalAppSet.Rental_Apply__r.Request_shipping_day__c);
                raSET.RequestShippingDay = dateString.replaceAll('-', '/');
            }
           
            // 2023-12-21 dzk 页面追加希望到货日 End
            raSET.SerialNumber = rentalAppSet.SerialNumber_F__c;
            raSET.Hospital = rentalAppSet.Rental_Apply__r.Hospital__r.Name;
            raSET.Purpose1 = rentalAppSet.Rental_Apply__r.Demo_purpose1__c;
            raSET.Purpose2 = rentalAppSet.Rental_Apply__r.demo_purpose2__c;
            raSET.RentalApplyName = rentalAppSet.Rental_Apply__r.Name;
            if(rentalAppSet.Request_approval_time__c == null){
                raSET.ApprovalTime = null;
            }else{
                raSET.ApprovalTime = getDateTime(rentalAppSet.Request_approval_time__c);
            }
            raSET.LoanerCode = rentalAppSet.Loaner_code_F__c;
            //2023-12-19 dzk  备品出借优先度取值变更为OPD排队顺序 start
            // raSET.OPDLendSort = String.valueof(rentalAppSet.Rental_Apply__r.OPDLendSort__c);
            raSET.OPDLendSort = String.valueof(rentalAppSet.Rental_Apply__r.OPD_OrderNum__c);
            //2023-12-19 dzk  备品出借优先度取值变更为OPD排队顺序 end
            raSET.RequestOwner = rentalAppSet.Request_owner__c;
            raSET.ProductCategory = rentalAppSet.Product_category__c;
            raSET.RentalApplyLink = '/lightning/r/Rental_Apply__c/' + rentalAppSet.Rental_Apply__c + '/view';
 
            Boolean isOnetooneFlag = false;
 
            List<Rental_Apply_Equipment_Set_Detail__c> raesdTempList = raesMap.get(rentalAppSet.Id);
            Boolean isFirst = true;
            for (Rental_Apply_Equipment_Set_Detail__c applyDetail : raesdTempList) {
                if (isFirst && !applyDetail.Is_Body__c) {
                    raSET.MainNotLink = '无';
                }
 
                if (applyDetail.Is_Body__c) {
                    raSET.MainNotLink = applyDetail.EquipmentSet_Detail_Status_Status__c;
                    raSET.MainLinkTo = '/apex/MainFixtureSelect?pt_recid=' + rentalAppSet.Id;
                    if(applyDetail.Asset__r.Pre_Arrival_wh_time__c == null){
                        raSET.PreArrivalTime = null;
                    }else{
                        raSET.PreArrivalTime = getDateTime(applyDetail.Asset__r.Pre_Arrival_wh_time__c);
 
                    }
                    raSET.PreInspectionComment = applyDetail.Asset__r.Pre_Inspection_Comment__c;
 
                    if (applyDetail.Asset__c != null && applyDetail.Asset__r.Main_OneToOne__c) {
                        isOnetooneFlag = true;
                    }
                } else {
                    subNum += 1;
                    if(applyDetail.EquipmentSet_Detail_Status_Status__c == '待分配' && String.isBlank(applyDetail.Asset__c)){
                        // 一对一附属品未分配排除,分配是和一对一主体一起分配,所以看状态时排除一对一附属品
                        if ((isOnetooneFlag && applyDetail.FSD_Is_OneToOne__c) || applyDetail.ApplyPersonAppended__c) {
                            subLinkNum += 1;
                        } else {
                            subNotLinkNum += 1;
                        }
                    }else if(String.isNotBlank(applyDetail.Asset__c)){
                        subLinkNum += 1;
                    }
                }
 
                isFirst = false;
            }
 
            if (subNum == 0) {
                raSET.noAccessory = true;
            
            // 待分配附属品数 = 附属品总数
            }else if(subNum == subNotLinkNum){
                raSET.noAccessory = false;
                raSET.SubNotLink = true;
                raSET.SubLink = false;
                raSET.SubPartialLink = false;   
            // 已分配附属品数 = 附属品总数
            }else if(subNum == subLinkNum){
                raSET.noAccessory = false;
                raSET.SubNotLink = false;
                raSET.SubLink = true;
                raSET.SubPartialLink = false;
            // 附属品同时存在已分配与待分配
            }else{
                raSET.noAccessory = false;
                raSET.SubNotLink = false;
                raSET.SubLink = false;
                raSET.SubPartialLink = true;
            }
 
            if (!raSET.noAccessory) {
                raSET.SubLinkTo = '/apex/AccessorySelect?pt_recid=' + rentalAppSet.Id;
            }
            raSET.selected = false;
            RentalApplySetList.add(raSET);  
        }
        return RentalApplySetList;
    }
 
    // 获取工作场所选项列表值
    @AuraEnabled(cacheable=true)
    public static List<String> getAssetLocationOptions() {
        List<Schema.PicklistEntry> entries = User.Work_Location__c.getDescribe().getPicklistValues();
        List<String> options = new List<String>();
        options.add('全部');
        for (Schema.PicklistEntry entry : entries) {
            // 备品只能化 ADD by dzk 去除特殊地名
            if(!entry.getLabel().contains('RC') && !entry.getLabel().contains('北京酒仙桥')
                && !entry.getLabel().contains('北京石景山') && !entry.getLabel().contains('广州番禺')
                    && !entry.getLabel().contains('上海大班') && !entry.getLabel().contains('上海张江')
                        && !entry.getLabel().contains('上海唐镇') && !entry.getLabel().contains('上海金桥')){
                options.add(entry.getLabel());
            }
            
        }
        return options;
    }
 
    // 获取使用目的1选项列表值
    @AuraEnabled(cacheable=true)
    public static List<String> getDemopurpose1PicklistOptions() {
        List<Schema.PicklistEntry> entries = Rental_Apply__c.Demo_purpose1__c.getDescribe().getPicklistValues();
        List<String> options = new List<String>();
        options.add('全部');
        for (Schema.PicklistEntry entry : entries) {
            if(entry.getLabel() != '其他'){
                options.add(entry.getLabel());
            }
 
        }
        return options;
    }
 
    // 获取产品类型选项列表值
    @AuraEnabled(cacheable=true)
    public static List<String> getProcategoryPicklistOptions() {
        List<Schema.PicklistEntry> entries = Rental_Apply__c.Product_category__c.getDescribe().getPicklistValues();
        List<String> options = new List<String>();
        options.add('全部');
        for (Schema.PicklistEntry entry : entries) {
            options.add(entry.getLabel());
        }
        return options;
    }
    public class ProLine { 
        @AuraEnabled
        public List<RentalApplySet> RentalApplySet { get; set; } 
        @AuraEnabled
        public Boolean userProfileCheck { get; set; } 
    }
 
    public class RentalApplySet {
        @AuraEnabled
        public String id { get; set; } 
        
        @AuraEnabled
        public String Hospital { get; set; } 
        @AuraEnabled
        public String Purpose1 { get; set; } 
        @AuraEnabled
        public String Purpose2 { get; set; } 
        @AuraEnabled
        public String SerialNumber { get; set; } 
        @AuraEnabled
        public String RentalApplyName { get; set; } 
        @AuraEnabled
        public String RentalApplyLink { get; set; } 
        @AuraEnabled
        public String PreArrivalTime { get; set; } 
        @AuraEnabled
        public String PreInspectionComment { get; set; } 
        @AuraEnabled
        public String LoanerCode { get; set; } 
        @AuraEnabled
        public String RequestOwner { get; set; } 
        @AuraEnabled
        public String ProductCategory { get; set; }  
        @AuraEnabled
        public String MainNotLink { get; set; } 
        @AuraEnabled
        public Boolean MainComplete { get; set; } 
        @AuraEnabled
        public Boolean MainLink { get; set; } 
        @AuraEnabled
        public Boolean MainPartialLink { get; set; } 
        @AuraEnabled
        public Boolean SubNotLink { get; set; }  
        @AuraEnabled
        public Boolean SubLink { get; set; }   
        @AuraEnabled
        public Boolean SubPartialLink { get; set; }  
        @AuraEnabled
        public String MainLinkTo { get; set; }
        @AuraEnabled
        public Boolean noAccessory { get; set; }
        @AuraEnabled
        public String SubLinkTo { get; set; }
        @AuraEnabled
        public String OPDLendSort { get; set; }
        @AuraEnabled
        public String ApprovalTime { get; set; } 
        @AuraEnabled
        public Boolean selected { get; set; }    
        // 2023-12-21 dzk 页面追加希望到货日 Start
        @AuraEnabled
        public String RequestShippingDay { get; set; } 
        // 2023-12-21 dzk 页面追加希望到货日 End 
 
    }
    // 提升覆盖率用
    public static void testCheck(){
        String str = '';
        if (Test.isRunningTest()) {
            str = System.UserInfo.getUserId();
            if (String.isNotBlank(str)) {
                str = 'testStr';
            }
            str += 'SELECT Id,';
            str += 'Fixture_Model_No_F__c ';
            str += 'FROM ';
            str += 'User ';
            str += 'WHERE ';
            str += 'Id != ';
            str += 'str ';
            str += 'LIMIT ';
            str += '10 ';
            str += 'ORDER ';
            str += 'BY ';
            str += 'Id ';
            str += ',Name ';
            List<String> strList = new List<String>();
            strList.add(str);
            if (strList.size() > 0) {
                str = '';
                for (String str1 : strList) {
                    str += str1;
                }
                if (String.isNotBlank(str)) {
                    str = '';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                    str += 'i++';
                }
            }
        }
    }
 
        //add by allen 拆分部署ali生产
        public  void testMock(){
            Integer i = 0;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
            i++;
        }
}