高章伟
2023-03-03 d8dc84a3d56df839895f1c417a4d9cbee763d262
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
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
public without sharing class RetrospectiveWeeklyReportController{
    @AuraEnabled public List<Agency_Report__c> reports{get;set;}
    @AuraEnabled public Map<String,List<Map<String,String>>> allselectlist{get;set;}
    @AuraEnabled public Map<String,String> fieldsMap{get;set;}
    @AuraEnabled public Map<String,List<Map<String,String>>> docmap{get;set;}
    @AuraEnabled public List<Map<String,String>> doctorList{get;set;}
    @AuraEnabled public String UserProType{get;set;}
    @AuraEnabled public Map<String,Agency_Report__c> AgencyReportMap{get;set;}
    @AuraEnabled public Map<String,string> PIConfig{get;set;}
    
    public RetrospectiveWeeklyReportController() {
    }
    public void UserDoin(){
        User UserProTypec = LightningUtil.loginUserId();
        this.UserProType = '';
        this.UserProType = UserProTypec.UserPro_Type__c;
    }
    
    public void setalldata()
    {
        /*** create allselectlist ***/
        this.allselectlist = new Map<String,List<Map<String,String>>>();
        //  用来存放工作会记录  和  效果/进度
        this.AgencyReportMap = new Map<String,Agency_Report__c>();
        
        Map<String,List<Map<String,String>>> alldata = new Map<String,List<Map<String,String>>>();
        system.debug('UserInfo.getUserId()11111111111================>'+UserInfo.getUserId());
        User login_user_id = [select UserPro_Type__c, ContactId,Contact.Name from User where id =: UserInfo.getUserId()];
        // プルダウン初期値の空白
        List<Map<String,String>> tmp = new List<Map<String,String>>();
        Map<String,String> space = new Map<String,String>();
        space.put('label', login_user_id.Contact.name);
        space.put('value', login_user_id.ContactId);
        space.put('selected', 'true');
        tmp.add(space);
        
        // 代理店担当者 AgencyPerson__c
        List<Contact> agency_person_data = LightningUtil.selectAgencyPerson03();
        for(Contact var : agency_person_data) {
            Map<String,String> om = new Map<String,String>();
            om.put('label', var.Name);
            om.put('value', var.Id);
            om.put('selected', 'false');
            tmp.add(om);
        }
        this.allselectlist.put('AgencyPerson__c', tmp);
        system.debug('tmp================>'+tmp);
        //经销商人员 
        List<Map<String,String>> tmp01 = new List<Map<String,String>>();
        Map<String,String> space01 = new Map<String,String>();
        space01.put('label', '');
        space01.put('value', '');
        space01.put('selected', 'true');
        tmp01.add(space01);
        // 经销商人员   DealerPersonnel__c
        List<Contact> agency_person_data01 = LightningUtil.selectAgencyPerson02();
        system.debug('agency_person_data01================>'+agency_person_data01);
        for(Contact var : agency_person_data01) {
            Map<String,String> om01 = new Map<String,String>();
            om01.put('label', var.Name);
            om01.put('value', var.Id);
            om01.put('selected', 'false');
            tmp01.add(om01);
        }
        this.allselectlist.put('DealerPersonnel__c', tmp01);
 
        // 科室分类 Department_Cateogy__c   AgencyReportMap
        this.allselectlist.put('Department_Cateogy__c', RetrospectiveWeeklyReportController.getPicklistValues('Agency_Report__c','Department_Cateogy__c'));
        
        // 活动区分会  WorkRecord__c
        this.allselectlist.put('WorkRecord__c', RetrospectiveWeeklyReportController.getPicklistValues('Agency_Report__c','WorkRecord__c'));
 
         // 效果进度  EffectProgress__c
        // this.allselectlist.put('EffectProgress__c', RetrospectiveWeeklyReportController.getPicklistValues('Agency_Report__c','EffectProgress__c'));
 
          // 产品分区  ET  或者  ENG   login_user_id
        //   if(login_user_id.UserPro_Type__c == 'ET')
        this.allselectlist.put('ProductClassification__c', RetrospectiveWeeklyReportController.getPicklistValues1('Agency_Report__c','ProductClassification__c'));
 
        // 产品1同类耗材科室月使用量    ConsumptionOfConsumables__c   
        this.allselectlist.put('ConsumptionOfConsumables__c', RetrospectiveWeeklyReportController.getPicklistValues('Agency_Report__c','ConsumptionOfConsumables__c'));
 
        //阶段 StageName__c   
        this.allselectlist.put('StageName__c', RetrospectiveWeeklyReportController.getPicklistValues('Agency_Opportunity__c','StageName__c'));
 
        //其他品牌耗材
        this.allselectlist.put('WarlockClassification__c', RetrospectiveWeeklyReportController.getPicklistValues('Agency_Report__c','WarlockClassification__c'));
 
        //产品类别
        this.allselectlist.put('ProductCcategory__c', RetrospectiveWeeklyReportController.getPicklistValues('Agency_Report__c','ProductCcategory__c'));
 
        //产品类别
        this.allselectlist.put('productCategories__c', RetrospectiveWeeklyReportController.getPicklistValues('Agency_Report__c','productCategories__c'));
 
        //其他品牌耗材
        this.allselectlist.put('warlocksNumber__c', RetrospectiveWeeklyReportController.getPicklistValues('Agency_Report__c','warlocksNumber__c'));
 
        //产品类别
        this.allselectlist.put('WorkMark__c', RetrospectiveWeeklyReportController.getPicklistValues('Agency_Report__c','WorkMark__c'));
        //拜访人
        // //fy 20220414
        // this.allselectlist.put('doctor3__c', RetrospectiveWeeklyReportController.getPicklistValues('Agency_Report__c','doctor3__c'));
        // 見出し設定
        this.fieldsMap = new Map<String,String>();
        this.fieldsMap = this.getfiledsmap();
        
        this.PIConfig = new Map<String,string>(); 
        this.PIConfig.put('staticResourceAgencyContact', JSON.serialize(PIHelper.getPIIntegrationInfo('Agency_Contact__c')));
    }
    
    @RemoteAction
    @AuraEnabled
    public static List<Map<String,String>> selectdoctor3c(){
        
        List<Map<String,String>> options = new List<Map<String,String>>();
        options = RetrospectiveWeeklyReportController.getPicklistValues('Agency_Report__c','doctor3__c');
        
        return options;
    }
    public static List<Map<String,String>> getPicklistValues(String objstr, String fld){
        List<Map<String,String>> options = new List<Map<String,String>>();
        Map<String,String> space = new Map<String,String>();
        space.put('label', '');
        space.put('value', '');
        space.put('selected', 'true');
        options.add(space);
        Schema.sObjectType objType = Schema.getGlobalDescribe().get(objstr);
        Schema.DescribeSObjectResult objDescribe = objType.getDescribe();
        map<String, Schema.SObjectField> fieldMap = objDescribe.fields.getMap();
        list<Schema.PicklistEntry> values = fieldMap.get(fld).getDescribe().getPickListValues();
        for (Schema.PicklistEntry a : values)
        {
            if (!a.isActive()) continue;
            Map<String,String> ses = new Map<String,String>();
            ses.put('label', a.getLabel());
            ses.put('value', a.getValue());
            ses.put('selected', 'false');
            options.add(ses);
        }
        return options;
    }
    public static List<Map<String,String>> getPicklistValues1(String objstr, String fld){
        List<Map<String,String>> options = new List<Map<String,String>>();
        Map<String,String> space = new Map<String,String>();
        User loginUserId = LightningUtil.loginUserId();
        Boolean fag = false;
        if(loginUserId.UserPro_Type__c == 'ET'){
            fag = true;
        }
        space.put('label', '');
        space.put('value', '');
        space.put('selected', 'true');
        options.add(space);
        Schema.sObjectType objType = Schema.getGlobalDescribe().get(objstr);
        Schema.DescribeSObjectResult objDescribe = objType.getDescribe();
        map<String, Schema.SObjectField> fieldMap = objDescribe.fields.getMap();
        list<Schema.PicklistEntry> values = fieldMap.get(fld).getDescribe().getPickListValues();
        for (Schema.PicklistEntry a : values)
        {
            if (!a.isActive()) continue;
            Map<String,String> ses = new Map<String,String>();
            if(fag){
                if(a.getValue() != '腹腔镜手术'&&a.getValue() != '开腹手术'){
                    ses.put('label', a.getLabel());
                    ses.put('value', a.getValue());
                    ses.put('selected', 'false');
                    options.add(ses);
                }
            }else{//fy 20220414
                if(a.getValue() == '腹腔镜手术'||a.getValue() == '开腹手术'){
                    ses.put('label', a.getLabel());
                    ses.put('value', a.getValue());
                    ses.put('selected', 'false');
                    options.add(ses);
                }
            }
        }
        return options;
    }
    
    
    public  Map<String,String> getfiledsmap()
    {
        Map<String,Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Map<String,List<String>>   typemap = new Map<String,List<String>>  ();
        //    Agency_Opportunity__c   经销商询价
        Map<String,Schema.SObjectField> fieldMap = schemaMap.get('Agency_Opportunity__c').getDescribe().fields.getMap();
        Map<String,String> mappingmap = new Map<String,String>();
        for(Schema.SObjectField sfield : fieldMap.Values())
        {
            Schema.describefieldresult dfield = sfield.getDescribe();
            String lab = '';
            lab = dfield.getLabel();
            mappingmap.put(dfield.name,lab);
        }
        //  Agency_Report__c   日报明细
        fieldMap = schemaMap.get('Agency_Report__c').getDescribe().fields.getMap();
        for(Schema.SObjectField sfield : fieldMap.Values())
        {
            Schema.describefieldresult dfield = sfield.getDescribe();
            String lab = '';
            lab = dfield.getLabel();
            mappingmap.put(dfield.name,lab);
        }
        return mappingmap;
    }
    
    @RemoteAction
    @AuraEnabled
    public static RetrospectiveWeeklyReportController getalldata(){
        RetrospectiveWeeklyReportController li = new RetrospectiveWeeklyReportController();
        li.UserDoin();
        li.setalldata();
        return li;
    }
 
    @RemoteAction
    @AuraEnabled
    public static ProductTypes__c getProduct(String id){//fy 修改Department_Cateogy_text__c
        return [select Department_Cateogy__c,Department_Cateogy_text__c, OPD_Flg__c, Id, SIS_Flg__c from ProductTypes__c where Id =:id];
    }
    
    @RemoteAction
    @AuraEnabled
    public static String createReportHeader(String name, String s_date, String s_agency, String head_key){
        Agency_Report_Header__c agency_report_header = makeReportHeader(name, s_date, s_agency, head_key);
        agency_report_header = LightningUtil.upsertAgencyReportHeader(agency_report_header);
        return agency_report_header.Id;
    }
    //新建日报一览
    public static Agency_Report_Header__c makeReportHeader(String name, String s_date, String s_agency, String head_key){
        User login_user_id = LightningUtil.loginUserId();
        Date week = Date.valueOf(s_date);
        Agency_Report_Header__c agency_report_header = new Agency_Report_Header__c();
        agency_report_header.Name = name + ' (' + s_date + ')';
        agency_report_header.HeaderInputKey__c = head_key;
        agency_report_header.Week__c = week;
        agency_report_header.Agency_Person2__c = s_agency;
        agency_report_header.WeeklyReportClassification__c =  login_user_id.UserPro_Type__c;
        OlympusCalendar__c olympus_calendar = [select Id,Date__c from OlympusCalendar__c where Date__c=:week];
        String olympus_calendar_id = olympus_calendar.Id;
        if (olympus_calendar_id != '') { agency_report_header.OlympusDate__c = olympus_calendar_id; }
        return agency_report_header;
    }
    
    @RemoteAction
    @AuraEnabled
    public static List<Agency_Hospital_Link__c> getHospitalList(String hospital_name) {
        User login_user_id = LightningUtil.loginUserId();
        String SignInId = UserInfo.getUserId();
        // List<Contact> conStrList = [select AccountId from contact where  id in (select ContactId from User where id =: SignInId)];
        Contact conStrList = [select AccountId from contact where  id in (select ContactId from User where id =: SignInId)];
 
        system.debug('conStrListconStrListr===============>'+conStrList);
        String strAgencyId =conStrList.AccountId;
        // for(Contact conStr : conStrList){
        //     strAgencyId = conStr.AccountId;
        // }
        system.debug('strAgencyIdstrAgencyId==============>'+strAgencyId);
        hospital_name = '%' + hospital_name.trim() + '%'; 
        if(login_user_id.UserPro_Type__c == 'ENG'){
            return [select Hospital_Name_readonly__c, Id, Hospital__c from Agency_Hospital_Link__c where Agency__c =: strAgencyId and Hospital_Name_readonly__c like :hospital_name and AgencyHos_ENG__c = true];
        }else {
            return [select Hospital_Name_readonly__c, Id, Hospital__c from Agency_Hospital_Link__c where Agency__c =: strAgencyId and Hospital_Name_readonly__c like :hospital_name and AgencyHos_ET__c = true];
        }
        
    }
 
    //模糊查询使用产品1
    @RemoteAction
    @AuraEnabled
    public static List<Product2> getUseProduct1(String UseProduct1Name,String select_ProductClassification) {
        String UseProduct1Name01 = '%' + UseProduct1Name.trim() + '%'; 
        User UserProTypec = LightningUtil.loginUserId();
        List<Product2> Product2List=new List<Product2>();
        List<String> select_ProductClassificationList = new  List<String>();
        if(select_ProductClassification=='其他'){
            select_ProductClassificationList.add('基干');
            select_ProductClassificationList.add('模型');
            select_ProductClassificationList.add('其他');
            select_ProductClassificationList.add('其他ET');
            select_ProductClassificationList.add('外科ET');
            select_ProductClassificationList.add('附属品');
        }else if(select_ProductClassification=='呼吸科'){
            select_ProductClassificationList.add('呼吸科ET');
        }else{
            select_ProductClassificationList.add(select_ProductClassification);
        }
        if(UserProTypec.UserPro_Type__c == 'ET'){
            Product2List =  [select Id, Name ,Asset_Model_No__c from Product2 where Category3__c in: select_ProductClassificationList AND Asset_Model_No__c like :UseProduct1Name01 AND Dealer_Object__c = true AND Estimation_Entry_Possibility__c = '○'];
        }else{
            Product2List =  [select Id, Name,Asset_Model_No__c  from Product2 where Category3__c in: select_ProductClassificationList AND Category4__c='Thunderbeat' AND Asset_Model_No__c like :UseProduct1Name01 AND ENG_DeaerProFlag__c = true AND Estimation_Entry_Possibility__c = '○'];
        }
        // if(UserProTypec.UserPro_Type__c == 'ET'){
        //     Product2List =  [select Id, Name ,Asset_Model_No__c from Product2 where Category3__c =: select_ProductClassification AND Asset_Model_No__c like :UseProduct1Name01 AND Dealer_Object__c = true AND Estimation_Entry_Possibility__c = '○'];
        // }else{
        //     Product2List =  [select Id, Name,Asset_Model_No__c  from Product2 where Category3__c =: select_ProductClassification AND Category4__c='Thunderbeat' AND Asset_Model_No__c like :UseProduct1Name01 AND ENG_DeaerProFlag__c = true AND Estimation_Entry_Possibility__c = '○'];
        // }
        return Product2List;
    }
            
    
    @RemoteAction
    @AuraEnabled
    public static List<Map<String,String>> getDoctorList(String hospital_id){
        List<Map<String,String>> ret = new List<Map<String,String>>();
        Map<String,String> space = new Map<String,String>();
        space.put('label', '');
        space.put('value', '');
        space.put('selected', 'true');
        ret.add(space);
        
        Agency_Hospital_Link__c ahl = [select Hospital__c from Agency_Hospital_Link__c where id = :hospital_id];
        List<Agency_Contact__c> doctor_list = [select id,Name,Doctor_Division1__c,
                                               AWS_Data_Id__c,// PI改造 By Bright 20220328
                                               Type__c,Agency_Hospital__c  
            FROM Agency_Contact__c WHERE Hospital_ID18__c=:ahl.Hospital__c order by Name];
        for (Agency_Contact__c row : doctor_list)
        {
            Map<String,String> tmp = new Map<String,String>();
            tmp.put('label', row.Name);
            tmp.put('value', row.Id);
            tmp.put('selected', 'false');
            tmp.put('Doctor_Division1__c', row.Doctor_Division1__c);
            tmp.put('AWS_Data_Id__c', row.AWS_Data_Id__c);// PI改造 By Bright 20220328
            ret.add(tmp);
        }
        return ret;
    }
    //删除周报明细
    @RemoteAction
    @AuraEnabled
    public static String deleteAgencyReport(String agencyReport_id){
        Savepoint sp = Database.setSavepoint();
        try{
            System.debug('agencyReport_id'+agencyReport_id);
            Agency_Report__c arrays = new Agency_Report__c();
            arrays.Id=agencyReport_id;
            delete arrays;
            return 'success';
        }catch(Exception e){
            Database.rollback(sp);
            System.debug('exception'+e);
            return e.getLineNumber()+'exception'+e;   
        }
    }
 
    @RemoteAction
    @AuraEnabled
    public static String saveAgencyReport(String Department_Cateogy,Decimal ConsumptionOfConsumables, 
                                            Boolean WorkMark,Decimal warlocksNumber,String DealerPersonnel,String ProductCcategory,String productCategories ,String WarlockClassification,
                                            String ProductClassification,String WorkRecord,String EffectProgress, String Agency_Report_Header,
                                                String Agency_Hospital, String Person_In_Charge2, String doctor, String Submit_date,
                                                String UseProduct1, String UseProduct2, String UseProduct3,
                                                String StageName, String oppAmount, String oppOCMPrice, String Close_Forecasted_Date, String Report_Date)
    {
        // Department_Cateogy = GetDepartment_Cateogy(Department_Cateogy);
        system.debug('Agency_Report_Header+++'+Agency_Report_Header);
        Agency_Report__c agency_report = makeAgencyReport(Department_Cateogy,ConsumptionOfConsumables,
        WorkMark,warlocksNumber,DealerPersonnel,ProductCcategory,productCategories,WarlockClassification,ProductClassification, WorkRecord,
        EffectProgress,Agency_Report_Header,
            Agency_Hospital, Person_In_Charge2, doctor, Submit_date,
            UseProduct1, UseProduct2, UseProduct3,
            StageName, oppAmount, oppOCMPrice, Close_Forecasted_Date, Report_Date);
 
        agency_report = insertAgencyReport(agency_report);
        return agency_report.Id;
    }
    public static Agency_Report__c makeAgencyReport(String Department_Cateogy,Decimal ConsumptionOfConsumables, 
    boolean WorkMark,Decimal warlocksNumber, String DealerPersonnel,String ProductCcategory,String productCategories,String WarlockClassification,
    String ProductClassification, String WorkRecord, String EffectProgress,String Agency_Report_Header,
            String Agency_Hospital, String Person_In_Charge2, String doctor, String Submit_date,
            String UseProduct1, String UseProduct2, String UseProduct3,
             String StageName, String oppAmount, String oppOCMPrice, String Close_Forecasted_Date, String Report_Date)
    {
        Agency_Report__c agency_report = new Agency_Report__c();
        Date week = Date.valueOf(Submit_date);
        agency_report.Submit_date__c = week;
        Date reportDate = Date.valueOf(Report_Date);
        agency_report.Report_Date__c = reportDate;
 
        // MaxActivityDate__c 更新
        if (Person_In_Charge2 != '') {
           
            if(Person_In_Charge2.contains(';')){
                Person_In_Charge2 = Person_In_Charge2.split(';')[0];
            }
            agency_report.Person_In_Charge2__c = Person_In_Charge2;
        } else {
            agency_report.Person_In_Charge2__c = null;
        }
        //经销商人员
        if (DealerPersonnel != '') {
            if(DealerPersonnel.contains(';')){
                DealerPersonnel = DealerPersonnel.split(';')[0];
            }
            agency_report.DealerPersonnel__c = DealerPersonnel;
        } else {
            agency_report.DealerPersonnel__c = null;
        }
        //更新经销商医院的 最近日报跟新日  , 
        if (Agency_Hospital != '')  {
            LightningUtil.updateAccMaxActivityDate(Agency_Hospital, week);
        }
        //fy 20220414
        if (doctor != '') {
            if(WorkRecord == '科室会'){
                agency_report.doctor3__c = doctor;
            }else{
                agency_report.doctor2__c = doctor; 
            }
        }else { 
            if(WorkRecord == '科室会'){
                agency_report.doctor3__c = null;
            }else{
                agency_report.doctor2__c = null; 
            }
        }
        // if (Department_Cateogy != '') { agency_report.Department_Cateogy__c = Department_Cateogy; }
        if (Department_Cateogy != '') { agency_report.Department_Cateogy_text__c = Department_Cateogy; }
        if (ConsumptionOfConsumables != null) { agency_report.ConsumptionOfConsumables__c = ConsumptionOfConsumables; }
        if (WorkRecord != '') { agency_report.WorkRecord__c = WorkRecord; }
        // system.debug('EffectProgress==================>'+EffectProgress);
        if (EffectProgress != '') { agency_report.EffectProgress__c = EffectProgress; }
        // ET    
        if (ProductClassification != '') { agency_report.ProductClassification__c = ProductClassification; }
        if (Agency_Report_Header != '') { agency_report.Agency_Report_Header__c = Agency_Report_Header; }
        if (Agency_Hospital != '') { agency_report.Agency_Hospital__c = Agency_Hospital; }
        if (UseProduct1 != '') { agency_report.UseProduct1__c = UseProduct1; }
        if (UseProduct2 != '') { agency_report.UseProduct2__c = UseProduct2; }
        if (UseProduct3 != '') { agency_report.UseProduct3__c = UseProduct3; }
        if (WarlockClassification != '') { agency_report.WarlockClassification__c = WarlockClassification; }  
        system.debug('ProductCcategory==================>'+ProductCcategory);
        if (ProductCcategory != '') { agency_report.ProductCcategory__c = ProductCcategory; }
        system.debug('productCategories==================>'+productCategories);
        if (productCategories != '') { agency_report.productCategories__c = productCategories; }
        if (warlocksNumber != null) { agency_report.warlocksNumber__c = warlocksNumber; }
        if (WorkMark != false) {
            agency_report.WorkMark__c = WorkMark; 
        }
        return agency_report;  
    }
    //新建方法
    public static Agency_Report__c insertAgencyReport(Agency_Report__c data) {
        if (String.isBlank(data.Hospital__c)) {
            system.debug('data.Agency_Hospital__c+++'+data.Agency_Hospital__c);
            List<Agency_Hospital_Link__c> agency_hospital_link = [select Id, Hospital__c from Agency_Hospital_Link__c where Id=:data.Agency_Hospital__c];
            system.debug('agency_hospital_link+++'+agency_hospital_link);
            data.Hospital__c = agency_hospital_link[0].Hospital__c;
        }
        // if (String.isBlank(data.Department_Class__c)) {
        //     system.debug('data.Department_Cateogy__c+++'+data.Department_Cateogy__c);
        //     String record_type_id = LightningUtil.getRecordTypeId(data.Department_Cateogy__c);
        //     system.debug('RecordTypeId+++'+record_type_id);
        //     List<Account> account = [select Id, RecordTypeId from account where Hospital_Department_Class__c=:data.Hospital__c and RecordTypeId=:record_type_id];
        //     system.debug('account+++'+account);
        //     data.Department_Class__c = account[0].Id;
        // }
        User userPro = LightningUtil.loginUserId();
        data.WeeklyReportClassification__c = userPro.UserPro_Type__c;
        system.debug('data==================>'+data);
 
        insert data;
        return data;
    }
    @RemoteAction
    @AuraEnabled
    public static String editAgencyReport(String Agency_Report_Id, String Department_Cateogy,
                                        Decimal ConsumptionOfConsumables,boolean WorkMark,Decimal warlocksNumber,
                                        String DealerPersonnel,String WarlockClassification,String ProductCcategory,String productCategories,String ProductClassification,
                                        String EffectProgress, String WorkRecord, String Agency_Report_Header,
                                        String Agency_Hospital, String Person_In_Charge2, String doctor, String Submit_date,
                                        String UseProduct1, String UseProduct2, String UseProduct3, 
                                         String Report_Date)
    {
        if (String.isBlank(Agency_Report_Id)) {
            return null;
        }//fy Department_Cateogy_text__c
        Agency_Report__c agency_report = [select Id,Hospital__c, Name, Department_Cateogy__c,Department_Cateogy_text__c, ConsumptionOfConsumables__c, WorkRecord__c,WarlockClassification__c,
                                            ProductCcategory__c, productCategories__c,warlocksNumber__c,WorkMark__c,ProductClassification__c,DealerPersonnel__c, Agency_Report_Header__c,Agency_Hospital__c,UseProduct1__c,
                                            UseProduct2__c, UseProduct3__c,  Person_In_Charge2__c,doctor2__c,doctor3__c,Submit_date__c,Report_Date__c
                                            from Agency_Report__c where id=:Agency_Report_Id];
        Date week = Date.valueOf(Submit_date);
        agency_report.Submit_date__c = week;
        Date reportDate = Date.valueOf(Report_Date);
        agency_report.Report_Date__c = reportDate;
 
        // MaxActivityDate__c 更新
        if (Person_In_Charge2 != '') {
            agency_report.Person_In_Charge2__c = Person_In_Charge2;
        } else {
            agency_report.Person_In_Charge2__c = null;
        }
 
        //经销商人员
        if (DealerPersonnel != '') {
            agency_report.DealerPersonnel__c = DealerPersonnel;
        } else {
            agency_report.DealerPersonnel__c = null;
        }
 
 
        if (Agency_Hospital != '')  {
            LightningUtil.updateAccMaxActivityDate(Agency_Hospital, week);
        }
        // WRITE Agency Report__c    String EffectProgress,  ConsumptionOfConsumables__c   WorkMark__c,warlocksNumber__c,
        if (doctor != '') { 
            if(WorkRecord == '科室会'){
                agency_report.doctor3__c = doctor; 
            }else{
                agency_report.doctor2__c = doctor; 
            }
        } else { 
            if(WorkRecord == '科室会'){
                agency_report.doctor3__c = null; 
            }else{
                agency_report.doctor2__c = null; 
            }
        }
        // if (Department_Cateogy != '') { agency_report.Department_Cateogy__c = Department_Cateogy; } else { agency_report.Department_Cateogy__c = null; }
        if (Department_Cateogy != '') { agency_report.Department_Cateogy_text__c = Department_Cateogy; } else { agency_report.Department_Cateogy_text__c = null; }
        if (WorkRecord != '') { agency_report.WorkRecord__c = WorkRecord; } else { agency_report.WorkRecord__c = null; }
        if (ConsumptionOfConsumables != null) { agency_report.ConsumptionOfConsumables__c = ConsumptionOfConsumables; } else { agency_report.ConsumptionOfConsumables__c = null; }
        if (EffectProgress != '') { agency_report.EffectProgress__c = EffectProgress; } else { agency_report.EffectProgress__c = null; }
        if (ProductClassification != '') { agency_report.ProductClassification__c = ProductClassification; } else { agency_report.ProductClassification__c = null; }
        if (Agency_Hospital != '') { agency_report.Agency_Hospital__c = Agency_Hospital; } else { agency_report.Agency_Hospital__c = null; }
        if (UseProduct1 != '') { agency_report.UseProduct1__c = UseProduct1; } else { agency_report.UseProduct1__c = null; }
        if (UseProduct2 != '') { agency_report.UseProduct2__c = UseProduct2; } else { agency_report.UseProduct2__c = null; }
        if (UseProduct3 != '') { agency_report.UseProduct3__c = UseProduct3; } else { agency_report.UseProduct3__c = null; }  
        if (ProductCcategory != '') { agency_report.ProductCcategory__c = ProductCcategory; } else { agency_report.ProductCcategory__c = null; }
        if (productCategories != '') { agency_report.productCategories__c = productCategories; } else { agency_report.productCategories__c = null; }
        if (WarlockClassification != '') { agency_report.WarlockClassification__c = WarlockClassification; } else { agency_report.WarlockClassification__c = null; }
        if (WorkMark != false) { agency_report.WorkMark__c = WorkMark; } else { agency_report.WorkMark__c = false; }
        if (warlocksNumber != null) { agency_report.warlocksNumber__c = warlocksNumber; } else { agency_report.warlocksNumber__c = null; }
        //fy 20220414
        // agency_report = LightningUtil.updateAgencyReport(agency_report);
        agency_report = updateAgencyReport(agency_report);
        
        return agency_report.Id;
    }
    //fy 20220414
    public static Agency_Report__c updateAgencyReport(Agency_Report__c data) {
        system.debug('data.Agency_Hospital__c++'+data.Agency_Hospital__c);
         system.debug('data.Id++'+data.Id);
        if (String.isBlank(data.Hospital__c)) {
            List<Agency_Hospital_Link__c> agency_hospital_link = [select Id, Hospital__c from Agency_Hospital_Link__c where Id=:data.Agency_Hospital__c];
            data.Hospital__c = agency_hospital_link[0].Hospital__c;
        }
        update data;
        return data;
    }
    @RemoteAction
    @AuraEnabled
    public static List<Agency_Opportunity__c> selectOpportunityByIdAndHospitalLinkId(String opportunity_id, String agency_hospital_link_id) {
        List<Agency_Opportunity__c> ret = new List<Agency_Opportunity__c>();
        
        ret = LightningUtil.selectOpportunityByIdAndHospitalLinkId(opportunity_id, agency_hospital_link_id);
        
        return ret;
    }
    
    @RemoteAction
    @AuraEnabled
    public static RetrospectiveWeeklyReportController getReports(String date_str, String person_str) {
        RetrospectiveWeeklyReportController li = new RetrospectiveWeeklyReportController();
        li.get_reports(date_str, person_str);
        return li;
    }
    
    public void get_reports(String date_str, String person_str) {     
        Date week = Date.valueOf(date_str);
        this.reports = LightningUtil.selectAgencyReport01(week, person_str);
    }
    
    @RemoteAction
    @AuraEnabled
    public static List<Agency_Report__c> getReportsById(String report_id) {
        system.debug('==report_id================>'+report_id);
        List<Agency_Report__c> ret = new List<Agency_Report__c>();
        ret = LightningUtil.selectAgencyReportById01(report_id);
        system.debug('==Agency_Report_Header__r.WeeklyReportClassification__c=================>'+ret);
        return ret;
    }
    
    // 批量添加日报by vivek start
    @RemoteAction
    @AuraEnabled
    public static List<Agency_Report__c> getReportsByDate(String date1, String date2) {
        Date date1_date = Date.valueOf(date1);
        Date date2_date = Date.valueOf(date2);
        RetrospectiveWeeklyReportController li = new RetrospectiveWeeklyReportController();
        List<Contact> conMList = LightningUtil.selectAgencyPerson03();
        return LightningUtil.selectMAgencyReport01(date1_date, date2_date, conMList);
    }
 
    public List<contact> selectMAgencyPerson() {
        String login_user_id = UserInfo.getUserId();
        return [select id, Name, Agency_User__c from contact];
    }
    // fy 导入 20220506 start
    @AuraEnabled
    public static String processDataAWSId(String fileData) {
        System.debug('fileData:::'+filedata);
       String errorMag = '';
       // 创建日报
       try{
            if(fileData!=null){ 
                String[] fileLines = new String[]{};
                fileLines = fileData.split('\n');
              
                // 经销商医院名称list
                List<String> ahlNameList = new List<String>();
                //for content
                system.debug('fileLines.size()==============>'+fileLines.size());
                for (Integer i=1,j=fileLines.size();i<j;i++){
                    List<String> inputvalues = new List<String>();
                    system.debug('fileLines[i]=    '+fileLines[i].replace(',','').trim()+'  +++');
                    if(fileLines[i].replace(',','').trim()!=''){
                        inputvalues = fileLines[i].split(',');
                        if(inputvalues != null){
                            if(inputvalues[1] == '' || inputvalues[1] == null){
                                errorMag += 'error1 第'+i+'行数据医院不能为空';
                            }
                            ahlNameList.add(inputvalues[1]);
                        }
                    }
                }
                system.debug('ahlNameList==============>'+ahlNameList);
                // 经销商医院的ocsm医院id的list
                List<String> ahlOcsmIdList = new List<String>();
                List<Agency_Hospital_Link__c> ahlList = [select id,name,Hospital__c,MaxActivityDate__c from Agency_Hospital_Link__c where name = :ahlNameList and Agency_Campaign_Obj__c = true];
            
                for(Agency_Hospital_Link__c ahl : ahlList){
                    ahlOcsmIdList.add(ahl.Hospital__c);
                }
                //List<Agency_Contact__c> doctor2list = [select id,Name,Doctor_Division1__c,Type__c,Agency_Hospital__c,AWS_Data_Id__c,Name_Encrypted__c FROM Agency_Contact__c WHERE Hospital_ID18__c= :ahlOcsmIdList order by Name];
                List<Agency_Contact__c> doctor2list = [select id,Name,Doctor_Division1__c,Type__c,Agency_Hospital__c,AWS_Data_Id__c FROM Agency_Contact__c WHERE Hospital_ID18__c= :ahlOcsmIdList order by Name];   //zhj 去掉Name_Encrypted__c 新方案改造 2023-12-21
                if(errorMag != ''){
                    return errorMag;
                }
                String doctor2listStr = JSON.serialize(doctor2list);
                return doctor2listStr;  
            }
        }catch(Exception e){
             System.debug('exception'+e);
             return e.getLineNumber()+'exception:'+e;   
        }
        return 'success';
    }
    //fy 调用pi改造的 获取url 和 token的方法
    @AuraEnabled
    public static Map<String,String> getAwsurl(String sobj){
        system.debug('进入getAwsurl');
        PIHelper.PIIntegration piIntegration = PIHelper.getPIIntegrationInfo(sobj);
        Map<String,String> awsmap = new Map<String,String>();
        awsmap.put('token', piIntegration.token);
        awsmap.put('newUrl', piIntegration.newUrl);
        awsmap.put('searchUrl', piIntegration.searchUrl);
        awsmap.put('transactionURL', piIntegration.transactionURL);
        return awsmap;
    }
    // fy 导入 20220506 end
    @AuraEnabled
    public static String processData(String fileData,String sobjectName,List<String> fields) {
       String errorMag = '';
       System.debug('fileData=================>'+fileData);
       // 创建日报
       try{
            if(fileData!=null){ 
                User UserProTypec = LightningUtil.loginUserId();
                String SignInId = UserInfo.getUserId();
 
                String[] fileLines = new String[]{};
                fileLines = fileData.split('\n');
                // 担当名称的list
                List<String> nameList = new List<String>();
                // 报告日的list
                List<Date> dateList = new List<Date>();
                // List<String> s_dateList = new List<String>();
                // 导入的数据
                List<List<String>> inputList = new List<List<String>>();
                // 经销商医院名称list
                List<String> ahlNameList = new List<String>();
                // 产品
                List<String> Product2NameList = new List<String>();
                // 效果进度
                List<String> EffectProgressList = new List<String>();
                // 术士分类
                List<String> OtherBrandConsumablesList = new List<String>();
                // 其他品牌耗材使用
                List<String> ProductCcategoryList = new List<String>();
                // 其他品牌耗材使用
                List<String> productCategoriesList = new List<String>();
                // 科室Set
                // Set<String> departmentSet = new Set<String>();
                // 经销商询价名称list
                // List<String> ahlOppNameList = new List<String>();
                //for content
                for (Integer i=1,j=fileLines.size();i<j;i++){
                    List<String> inputvalues = new List<String>();
                    if(fileLines[i].replace(',','').trim()!=''){
                        inputvalues = fileLines[i].split(',');
                        system.debug('inputvalues:::::::'+inputvalues);
                        if(inputvalues != null){
                            // if(inputvalues[0] == '' || inputvalues[0] == null){
                            //     errorMag += 'error1 第'+i+'行数据周不能为空';
                            //     errorMag += '=';
                            // }
                            // if(inputvalues[0] == '' || inputvalues[0] == null){
                            //     errorMag += 'error1 第'+i+'行数据担当不能为空';
                            //     errorMag += '=';
                            // }
                            if(inputvalues[0] == '' || inputvalues[0] == null){
                                errorMag += 'error1 第'+i+'行数据活动日不能为空';
                                errorMag += '=';
                            }
                            if(inputvalues[1] == '' || inputvalues[1] == null){
                                errorMag += 'error1 第'+i+'行数据医院不能为空';
                                errorMag += '=';
                            }
                            if(inputvalues[2] == '' || inputvalues[2] == null){
                                errorMag += 'error1 第'+i+'行数据科室不能为空';
                                errorMag += '=';
                            }
                            //fy 20220414
                            // String departmentstr = GetDepartment_Cateogy(inputvalues[2]);
                            // if(departmentstr == 'no' && inputvalues[2] != '' && inputvalues[2] != null){
                            // if(inputvalues[2] != '' && inputvalues[2] != null){
                            //     errorMag += 'error3 第'+i+'行数据科室选项列表的值'+inputvalues[2]+'不存在';
                            //     errorMag += '=';
                            // }
                            if(inputvalues[3] == '' || inputvalues[3] == null){
                                errorMag += 'error1 第'+i+'行数据经销商人员不能为空';
                                errorMag += '=';
                            }
                            if(inputvalues[4] == '' || inputvalues[4] == null){
                                errorMag += 'error1 第'+i+'行数据活动区分不能为空';
                                errorMag += '=';
                            }
                            boolean purposeType = GetPurposeType(inputvalues[4]);
                            if(!purposeType && inputvalues[4] != '' && inputvalues[4] != null){
                                errorMag += 'error3 第'+i+'行数据活动区分选项列表的值'+inputvalues[4]+'不存在';
                                errorMag += '=';
                            }
                            if(inputvalues[4] == 'SIS'||inputvalues[4] == '科室会'||inputvalues[4] == '院内入院申请'||inputvalues[4] == '收费项目申请'){
                                if(inputvalues[5] == '' || inputvalues[5] == null){
                                    errorMag += 'error1 第'+i+'行数据拜访人不能为空';
                                    errorMag += '=';
                                }
                            }
                            if(inputvalues[6] == '' || inputvalues[6] == null){
                                errorMag += 'error1 第'+i+'行数据产品分类(第三分类)不能为空';
                                errorMag += '=';
                            }
                            // if(inputvalues[4] != '临床信息(使用量)收集' && inputvalues[4] != 'QIS处理'){
                            if(inputvalues[4] != '临床信息(使用量)收集' ){
                                if(inputvalues[7] == '' || inputvalues[7] == null){
                                    errorMag += 'error1 第'+i+'行数据使用产品1不能为空';
                                    errorMag += '=';
                                }
                            }
                            if((inputvalues[8] != '' && inputvalues[8] != null)&& inputvalues[7] == inputvalues[8]){
                                errorMag += 'error1 第'+i+'行数据使用产品1和使用产品2的值不能重复';
                                errorMag += '=';
                            }
                            if((inputvalues[9] != '' && inputvalues[9] != null)&& inputvalues[7] == inputvalues[9]){
                                errorMag += 'error1 第'+i+'行数据使用产品1和使用产品3的值不能重复';
                                errorMag += '=';
                            }
                            if((inputvalues[8] != '' && inputvalues[8] != null) && (inputvalues[9] != '' && inputvalues[9] != null) && inputvalues[8] == inputvalues[9]){
                                errorMag += 'error1 第'+i+'行数据使用产品2和使用产品3的值不能重复';
                                errorMag += '=';
                            }
                            if(inputvalues[4] != '临床信息(使用量)收集' && inputvalues[4] != '市场推广类活动'){
                                if(inputvalues[10] == '' || inputvalues[10] == null){
                                    errorMag += 'error1 第'+i+'行数据效果/进度不能为空';
                                    errorMag += '=';
                                }
                            }
                            if(inputvalues[4] == '临床信息(使用量)收集'){
                                if(inputvalues[11] == '' || inputvalues[11] == null){
                                    errorMag += 'error1 第'+i+'行数据产品1同类耗材科室月使用量不能为空';
                                    errorMag += '=';
                                }
                            }
                            if(inputvalues[11] != '' && inputvalues[11] != null){
                                boolean wanked = wncc(inputvalues[11]);
                                // if(!wanked && inputvalues[11] == '' || inputvalues[11] == null){
                                if(!wanked){
                                    errorMag += 'error3 第'+i+'行数据错误,请检查你的产品1同类耗材科室月使用量!';
                                    errorMag += '=';
                                }
                            }
                            //暂时注掉因为ENG的术士分类为空所以暂时注掉
                            if(inputvalues[4] == '临床信息(使用量)收集'){
                                if(inputvalues[12] == '' || inputvalues[12] == null){
                                    errorMag += 'error1 第'+i+'行数据产品1对应术式分类不能为空';
                                    errorMag += '=';
                                }
                            }
                            if(inputvalues[4] == '临床信息(使用量)收集'){
                                if(inputvalues[13] == '' || inputvalues[13] == null){
                                    errorMag += 'error1 第'+i+'行数据已采用其他产品不能为空';
                                    errorMag += '=';
                                }
                            }
                            //暂时注掉因为ET的其他品牌产品类别没有数据
                            if(inputvalues[4] == '临床信息(使用量)收集' && UserProTypec.UserPro_Type__c =='ENG'){
                                if(inputvalues[14] == '' || inputvalues[14] == null){
                                    errorMag += 'error1 第'+i+'行数据术士使用产品对应数量不能为空';
                                    errorMag += '=';
                                }
                            }
                            if(inputvalues[4] == '临床信息(使用量)收集'){
                                if(inputvalues[15] == '' || inputvalues[15] == null){
                                    errorMag += 'error1 第'+i+'行数据产品用量不能为空';
                                    errorMag += '=';
                                }
                            }
                            if(inputvalues[15] != '' && inputvalues[15] != null){
                                boolean wankeds = wncc(inputvalues[15]);
                                if(!wankeds){
                                    errorMag += 'error3 第'+i+'行数据错误,请检查你的产品用量!';
                                    errorMag += '=';
                                }
                            }
                            system.debug('inputvalues[0]====='+inputvalues[0]);
                            system.debug('inputvalues[1]====='+inputvalues[1]);
                            system.debug('inputvalues[2]====='+inputvalues[2]);
                            system.debug('inputvalues[3]====='+inputvalues[3]);
                            system.debug('inputvalues[4]====='+inputvalues[4]);
                            system.debug('inputvalues[5]====='+inputvalues[5]);
                            system.debug('inputvalues[6]====='+inputvalues[6]);
                            system.debug('inputvalues[7]====='+inputvalues[7]);
                            system.debug('inputvalues[8]====='+inputvalues[8]);
                            system.debug('inputvalues[9]====='+inputvalues[9]);
                            system.debug('inputvalues[10]====='+inputvalues[10]);
                            system.debug('inputvalues[11]====='+inputvalues[11]);
                            system.debug('inputvalues[12]====='+inputvalues[12]);
                            system.debug('inputvalues[13]====='+inputvalues[13]);
                            system.debug('inputvalues[14]====='+inputvalues[14]);
                            system.debug('inputvalues[15]====='+inputvalues[15]);
                            system.debug('inputvalues[16]====='+inputvalues[16]);
                            // system.debug('inputvalues[17]====='+inputvalues[17]);
                            //担当
                            // nameList.add(inputvalues[1]);
                            //报告日
                            dateList.add(Date.valueOf(inputvalues[0].replace('/','-')));
 
                            //经销商医院
                            ahlNameList.add(inputvalues[1]);
                            //使用产品1
                            Product2NameList.add(inputvalues[7]);
                            //使用产品2
                            Product2NameList.add(inputvalues[8]);
                            //使用产品3
                            Product2NameList.add(inputvalues[9]);
                            //效果进度
                            EffectProgressList.add(inputvalues[10]);
                            //术士分类
                            OtherBrandConsumablesList.add(inputvalues[12]);
                            //已采用其他品牌
                            ProductCcategoryList.add(inputvalues[13]);
                            //其他品牌产品类别
                            productCategoriesList.add(inputvalues[14]);
                            //科室
                            // departmentSet.add('%'+GetDepartment_Cateogy(inputvalues[2])+'%'+'-'+GetEPurposeType(inputvalues[8]));
                            //导入的数据
                            inputList.add(inputvalues);
                        }
                    }
                }
                // 担当名称匹配的map
                Map<String,String> nameIdMap = new Map<String,String>();
                Map<String,String> nameConMap = new Map<String,String>();
                // 经销商医院名称匹配的map
                Map<String,Agency_Hospital_Link__c> ahlMap = new Map<String,Agency_Hospital_Link__c>();
                // 经销商医院的ocsm医院id的list
                List<String> ahlOcsmIdList = new List<String>();
                // 经销商医院id的List
                List<String> ahlIdList = new List<String>();
                // 使用产品1,2,3
                Map<String,Product2> UseProductMap = new Map<String,Product2>();
                // 效果进度
                Map<String,FieldClassification__c> EffectProgressMap = new Map<String,FieldClassification__c>();
                // 术士分类
                Map<String,FieldClassification__c> OtherBrandConsumablesMap = new Map<String,FieldClassification__c>();
                Map<String,AggregateResult> OtherBrandConsumablesMap2 = new Map<String,AggregateResult>();
                // 已采用其他产品
                Map<String,FieldClassification__c> ProductCcategorynMap = new Map<String,FieldClassification__c>();  
                 // 其他品牌产品类别
                 Map<String,FieldClassification__c> productCategoriesMap = new Map<String,FieldClassification__c>();  
                // 使用产品id的List
                List<String> UseProductIdList = new List<String>();
                 // 效果进度id的List
                 List<String> EffectProgressIdList = new List<String>();
                  // 术士分类id的List
                List<String> OtherBrandConsumablesIdList = new List<String>();
                  // 已采用其他品牌id的List   
                  List<String> ProductCcategorynIdList = new List<String>();
                  // 其他品牌产品类别id的List   productCategoriesMap
                  List<String> productCategoriesIdList = new List<String>();
                // 产品区分的map
                Map<String,String> protypeMap = new Map<String,String>();
                // 获取每周第一天的map
                Map<Date,Date> dateMap = new Map<Date,Date>();
                // 根据日期获取olympus日历id的map
                Map<Date,String> dateIdMap = new Map<Date,String>();
                // 根据经销商医院的ocsm医院获取的所有.客户人员的信息的名称和id的map  DealerPersonnelMap
                Map<String,String> doctor2Map = new Map<String,String>();
                //存放经销商人员的Map
                Map<String,String> DealerPersonnelMap = new Map<String,String>();
                // 经销商询价的map
                Map<String,Agency_Opportunity__c> aoMap = new Map<String,Agency_Opportunity__c>();
                //术式分类 的连个下拉选项
                List<FieldClassification__c> FieldClassification2List;
                List<AggregateResult> WarlockClassificationList2;
 
                List<Contact> conList = LightningUtil.selectAgencyPerson03();      
                List<OlympusCalendar__c> olympusDateList = [select Id,Date__c,FirstDayOfWeek__c,DayOfTheWeek__c from OlympusCalendar__c where Date__c= :dateList ];
                //医院
                List<Agency_Hospital_Link__c> ahlList;
                Contact conStrList = [select AccountId from contact where  id in (select ContactId from User where id =: SignInId)];
                String strAgencyId =conStrList.AccountId;
                System.debug('UserProTypec.UserPro_Type__c = ' + UserProTypec.UserPro_Type__c);
                if(UserProTypec.UserPro_Type__c == 'ENG'){
                    ahlList =  [select id,name,Hospital__c,MaxActivityDate__c from Agency_Hospital_Link__c where Agency__c =: strAgencyId and name = :ahlNameList and AgencyHos_ENG__c = true and Agency_Campaign_Obj__c = true];
                }else {
                    ahlList =  [select id,name,Hospital__c,MaxActivityDate__c from Agency_Hospital_Link__c where Agency__c =: strAgencyId and name = :ahlNameList and AgencyHos_ET__c = true and Agency_Campaign_Obj__c = true];
                }
                // List<Agency_Hospital_Link__c> ahlList = [select id,name,Hospital__c,MaxActivityDate__c from Agency_Hospital_Link__c where name = :ahlNameList and Agency_Campaign_Obj__c = true];
                //使用产品
                List<Product2> pr2List;
                if(UserProTypec.UserPro_Type__c == 'ET'){
                    pr2List =  [select Id, Name,Category3__c,Asset_Model_No__c  from Product2 where Asset_Model_No__c in:Product2NameList AND Dealer_Object__c = true AND Estimation_Entry_Possibility__c = '○'];
                }else{
                    pr2List =  [select Id, Name,Category3__c,Asset_Model_No__c  from Product2 where Category4__c='Thunderbeat' AND Asset_Model_No__c in:Product2NameList AND ENG_DeaerProFlag__c = true AND Estimation_Entry_Possibility__c = '○'];
                }
                system.debug('pr2List++'+pr2List);
                // List<Product2> pr2List = [select id,name from Product2 where name in:Product2NameList];
                List<FieldClassification__c> FieldClassification1List = [select id,EffectProgress__c from FieldClassification__c where EffectProgress__c  in :EffectProgressList]; 
                if(UserProTypec.UserPro_Type__c =='ET'){
                    FieldClassification2List = [select id,WarlockClassification__c from FieldClassification__c where WarlockClassification__c in :OtherBrandConsumablesList];
                }else{
                    WarlockClassificationList2 = [select count(id) sum, Category4__c from product2 where ENG_DeaerProFlag__c  = true group by Category4__c ];
                }
                List<FieldClassification__c> FieldClassification3List = [select id,ProductCcategory__c from FieldClassification__c where ProductCcategory__c in :ProductCcategoryList];
                List<FieldClassification__c> FieldClassification4List = [select id,productCategories__c from FieldClassification__c where productCategories__c in :productCategoriesList];
                
                for(OlympusCalendar__c olym : olympusDateList){
                    if(olym.DayOfTheWeek__c == 'Sun'){
                        dateMap.put(olym.Date__c, olym.Date__c.addDays(1));
                    }
                    else{
                        dateMap.put(olym.Date__c, olym.FirstDayOfWeek__c);
                    }
                }
                List<OlympusCalendar__c> olympusIdList = [select Id,Date__c,FirstDayOfWeek__c from OlympusCalendar__c where Date__c= :dateMap.values()];
                for(OlympusCalendar__c olym : olympusIdList){
                    dateIdMap.put(olym.FirstDayOfWeek__c, olym.id);
                }
                // for(Contact con :conList){
                //     nameIdMap.put(con.Name.replace(' ',''), con.Id);
                //     nameConMap.put(con.Id, con.Name);
                // }
                // return testuse;
                System.debug('ahlList = ' + ahlList);
                for(Agency_Hospital_Link__c ahl : ahlList){
                    ahlMap.put(ahl.Name, ahl);
                    ahlOcsmIdList.add(ahl.Hospital__c);
                    ahlIdList.add(ahl.Id);
                }
                for(Product2 pr2 : pr2List){
                    UseProductMap.put(pr2.Asset_Model_No__c, pr2);
                    UseProductIdList.add(pr2.Id);
                }
                for(FieldClassification__c ep : FieldClassification1List){
                    EffectProgressMap.put(ep.EffectProgress__c, ep);
                    EffectProgressIdList.add(ep.Id);
                }
                //术式分类
                if(UserProTypec.UserPro_Type__c =='ET'){
                    for(FieldClassification__c oc : FieldClassification2List){ 
                        OtherBrandConsumablesMap.put(oc.WarlockClassification__c, oc);
                        OtherBrandConsumablesIdList.add(oc.Id);
                    }
                }else{
                    for(AggregateResult oc : WarlockClassificationList2){ 
                        OtherBrandConsumablesMap2.put(string.valueOf(oc.get('Category4__c')), oc);
                    }
                }
                
                for(FieldClassification__c pc : FieldClassification3List){ 
                    ProductCcategorynMap.put(pc.ProductCcategory__c, pc);
                    ProductCcategorynIdList.add(pc.Id);
                }
                for(FieldClassification__c pct : FieldClassification4List){ 
                    productCategoriesMap.put(pct.productCategories__c, pct);
                    productCategoriesIdList.add(pct.Id);
                }
                // List<Agency_Contact__c> doctor2list = [select id,Name,Doctor_Division1__c,Type__c,Agency_Hospital__c FROM Agency_Contact__c WHERE Hospital_ID18__c= :ahlOcsmIdList order by Name];
                //List<Agency_Contact__c> doctor2list = [select id,Name,Doctor_Division1__c,Type__c,Agency_Hospital__c,AWS_Data_Id__c,Name_Encrypted__c FROM Agency_Contact__c WHERE Hospital_ID18__c= :ahlOcsmIdList order by Name];
                List<Agency_Contact__c> doctor2list = [select id,Name,Doctor_Division1__c,Type__c,Agency_Hospital__c,AWS_Data_Id__c FROM Agency_Contact__c WHERE Hospital_ID18__c= :ahlOcsmIdList order by Name];   //zhj 去掉Name_Encrypted__c 新方案改造 2022-12-21
                for(Agency_Contact__c ac : doctor2list){
                    // doctor2Map.put(ac.Name.replace(' ',''), ac.Id);
                    //doctor2Map.put(ac.Name_Encrypted__c, ac.Id);          //zhj 新方案改造 2022-12-21
                    doctor2Map.put(ac.AWS_Data_Id__c, ac.Id);  
                }
                //经销商人员  DealerPersonnel
                List<contact> conListLighrningUtil = LightningUtil.selectAgencyPerson02();
                for(contact de : conListLighrningUtil){
                    DealerPersonnelMap.put(de.Name.replace(' ',''), de.Id);
                }
                // 创建日报
                List<Agency_Report_Header__c> agency_report_headerlist = new List<Agency_Report_Header__c>();
                Map<String,Agency_Report_Header__c> agency_report_headerMap = new Map<String,Agency_Report_Header__c>();
                //zxk 存放担当
                for(List<String> lineList :inputList){
                    Date week = Date.today();
                    String s_agency = null;
                    String s_agencyname = null;
                    if(dateMap.get(Date.valueOf(lineList[0].replace('/','-'))) != null){
                        week = dateMap.get(Date.valueOf(lineList[0].replace('/','-')));
                    }
                    // if(nameIdMap.get(lineList[0].replace(' ','')) != null){
                        // s_agency = nameIdMap.get(lineList[0].replace(' ',''));
                        // s_agencyname = nameConMap.get(nameIdMap.get(lineList[0].replace(' ','')));
                    if(conList != null &&conList.size()!=0){
                        s_agency = conList[0].Id;
                        s_agencyname = conList[0].Name;
                    }
                    Agency_Report_Header__c agency_report_header = new Agency_Report_Header__c();
                    agency_report_header.Name = s_agencyname + ' (' + week.format().replace('/','-') + ')';
                    agency_report_header.HeaderInputKey__c = createHeader(week,s_agency);
                    agency_report_header.Week__c = week;
                    agency_report_header.Agency_Person2__c = s_agency;
                    if(dateIdMap.containsKey(week)){
                        agency_report_header.OlympusDate__c = dateIdMap.get(week);
                    }
                    if(s_agencyname != null && s_agencyname != '' && s_agencyname != 'null'){
                        agency_report_headerMap.put(agency_report_header.HeaderInputKey__c, agency_report_header);
                    }
                    
                }
                agency_report_headerlist = agency_report_headerMap.values();
                if(agency_report_headerlist.size() > 0){
                    LightningUtil.upsertMAgencyReportHeader(agency_report_headerlist);
                }
                List<Agency_Report__c> arList = new List<Agency_Report__c>();
                Integer hang = 1;
                User UserPro = LightningUtil.loginUserId();
                String UserProTypeStr = UserPro.UserPro_Type__c;
                for(List<String> lineList :inputList){
                    // 创建日报明细
                    Date week = null;
                    String s_agency = null;
                    if(dateMap.get(Date.valueOf(lineList[0].replace('/','-'))) != null){
                        week = dateMap.get(Date.valueOf(lineList[0].replace('/','-')));
                    }
                    // if(nameIdMap.get(lineList[0].replace(' ','')) != null){
                    //     s_agency = nameIdMap.get(lineList[0].replace(' ',''));
                    // }
                    if(conList != null &&conList.size()!=0){
                        s_agency = conList[0].Id;
                    }
                    Agency_Report__c agencyReport = new Agency_Report__c();
                    if(week == null && lineList[0] != '' && lineList[0] != null){
                        errorMag += 'error2 第'+hang+'行数据报告日  '+lineList[0]+'填写有误';
                        errorMag += '=';
                    }
                    agencyReport.Submit_date__c = week;   
                    // if((s_agency == null || s_agency == '')&& lineList[0] != '' && lineList[0] != null){
                    //     errorMag += 'error2 第'+hang+'行数据担当'+lineList[0]+'不存在';
                    //     errorMag += '=';
                    // }
                    agencyReport.Person_In_Charge2__c = s_agency;  
                    if(lineList[0] != null && lineList[0] != ''){
                        agencyReport.Report_Date__c = Date.valueOf(lineList[0].replace('/','-')); 
                    }
                    System.debug('ahlMap = ' + ahlMap);
                    System.debug('lineList[1] = ' + lineList[1]);
                    if(ahlMap.containsKey(lineList[1])){
                        agencyReport.Agency_Hospital__c = ahlMap.get(lineList[1]).Id;    
                        ahlMap.get(lineList[1]).MaxActivityDate__c = week;
                    }else{
                        if(lineList[1] != '' && lineList[1] != null){
                            errorMag += 'error2 第'+hang+'行数据经销商医院  '+lineList[1]+'不存在';
                            errorMag += '=';
                        }
                    }
                    // String departmentE = GetDepartment_Cateogy(lineList[2]);
                    // if(departmentE != 'no'){// fy Department_Cateogy_text__c
                        // agencyReport.Department_Cateogy__c = departmentE;  
                        agencyReport.Department_Cateogy_text__c =lineList[2];
                    // }else{
                    // }
                    if(DealerPersonnelMap.containsKey(lineList[3].replace(' ',''))){ 
                        agencyReport.DealerPersonnel__c = DealerPersonnelMap.get(lineList[3].replace(' ','')); 
                    }else{
                        if(lineList[3] != '' && lineList[3] != null){
                            errorMag += 'error2 第'+hang+'行数据经销商人员  '+lineList[3]+'不存在';
                            errorMag += '=';
                        }
                    }
                    if(GetPurposeType(lineList[4])){
                        agencyReport.WorkRecord__c = lineList[4]; 
                    }
                    if(agencyReport.WorkRecord__c == '科室会'){
                        if(lineList[5]=='医生'||lineList[5]=='医生+护士'||lineList[5]=='医生+护士'){
                            agencyReport.doctor3__c = lineList[5];
                        }else{
                            if(lineList[5] != '' && lineList[5] != null){
                                errorMag += 'error2 第'+hang+'行数据拜访人  '+lineList[5]+'不存在';
                                errorMag += '=';
                            }
                        }
                    }else{
                        // if(doctor2Map.containsKey(lineList[5].replace(' ',''))){ 
                        if(doctor2Map.containsKey(lineList[5])){ 
                            // if(agencyReport.WorkRecord__c == '科室会'){
                            //     agencyReport.doctor3__c = doctor2Map.get(lineList[5].replace(' ',''));
                            // }else{
                                // agencyReport.doctor2__c = doctor2Map.get(lineList[5].replace(' ','')); 
                                agencyReport.doctor2__c = doctor2Map.get(lineList[5]); 
                            // }
                        }else{
                            if(lineList[5] != '' && lineList[5] != null){
                                errorMag += 'error2 第'+hang+'行数据客户人员  '+lineList[5]+'不存在';
                                errorMag += '=';
                            }
                        }
                    }
                    if(GetProductClassification(lineList[6])){
                        agencyReport.ProductClassification__c = lineList[6];  
                    }
                    system.debug('UseProductMap+++'+UseProductMap);
                    system.debug('agencyReport.ProductClassification__c+++'+agencyReport.ProductClassification__c);
                    if(UseProductMap.containsKey(lineList[7])){
                        if(UseProductMap.get(lineList[7]).Category3__c==agencyReport.ProductClassification__c){
                            agencyReport.UseProduct1__c = UseProductMap.get(lineList[7]).Id; 
                        }else{
                            errorMag += 'error2 第'+hang+'行数据使用产品1产品型号  '+lineList[7]+'和第三分类无法匹配';
                            errorMag += '=';
                        }
                        // agencyReport.UseProduct1__c = UseProductMap.get(lineList[7]).Id;
                    }else{
                        if(lineList[7] != '' && lineList[7] != null){
                            errorMag += 'error2 第'+hang+'行数据使用产品1  '+lineList[7]+'不存在';
                            errorMag += '=';
                        }
                    }
 
                    if(UseProductMap.containsKey(lineList[8])){
                        if(UseProductMap.get(lineList[8]).Category3__c==agencyReport.ProductClassification__c){
                            agencyReport.UseProduct2__c = UseProductMap.get(lineList[8]).Id; 
                        }else{
                            errorMag += 'error2 第'+hang+'行数据使用产品2产品型号  '+lineList[8]+'和第三分类无法匹配';
                            errorMag += '=';
                        }
                        // agencyReport.UseProduct2__c = UseProductMap.get(lineList[8]).Id;  
                    }else{
                        if(lineList[8] != '' && lineList[8] != null){
                            errorMag += 'error2 第'+hang+'行数据使用产品2  '+lineList[8]+'不存在';
                            errorMag += '=';
                        }
                    }
                    if(UseProductMap.containsKey(lineList[9])){
                        if(UseProductMap.get(lineList[9]).Category3__c==agencyReport.ProductClassification__c){
                            agencyReport.UseProduct3__c = UseProductMap.get(lineList[9]).Id;  
                        }else{
                            errorMag += 'error2 第'+hang+'行数据使用产品3产品型号  '+lineList[9]+'和第三分类无法匹配';
                            errorMag += '=';
                        }
                        // agencyReport.UseProduct3__c = UseProductMap.get(lineList[9]).Id;  
                    }else{
                        if(lineList[9] != '' && lineList[9] != null){
                            errorMag += 'error2 第'+hang+'行数据使用产品3  '+lineList[9]+'不存在';
                            errorMag += '=';
                        }
                    }
                    if(EffectProgressMap.containsKey(lineList[10])){
                        agencyReport.EffectProgress__c = EffectProgressMap.get(lineList[10]).EffectProgress__c;    
                    }
                    boolean wankeds1 = wncc(lineList[11]);
                    if(lineList[11] != null && lineList[11] != ''&&wankeds1){
                        agencyReport.ConsumptionOfConsumables__c = Decimal.valueOf(lineList[11]);     
                    }
                    if(UserProTypec.UserPro_Type__c =='ET'){
                        if(OtherBrandConsumablesMap.containsKey(lineList[12])){
                            agencyReport.WarlockClassification__c = OtherBrandConsumablesMap.get(lineList[12]).WarlockClassification__c;     
                        }
                        // else{
                        //     if(lineList[12]!=null &&lineList[12]!=''){
                        //         errorMag += 'error2 第'+hang+'行数据产品1对应术式分类'+lineList[12]+'不存在';
                        //         errorMag += '=';
                        //     }
                        // }
                    }else{
                        if(OtherBrandConsumablesMap2.containsKey(lineList[12])){
                            agencyReport.WarlockClassification__c = string.valueOf(OtherBrandConsumablesMap2.get(lineList[12]).get('Category4__c'));     
                        }
                        // else{
                        //     if(lineList[12]!=null &&lineList[12]!=''){
                        //         errorMag += 'error2 第'+hang+'行数据产品1对应术式分类'+lineList[12]+'不存在';
                        //         errorMag += '=';
                        //     }
                        // }
                    }
                    if(ProductCcategorynMap.containsKey(lineList[13])){   
                        agencyReport.ProductCcategory__c = ProductCcategorynMap.get(lineList[13]).ProductCcategory__c;      
                    }
                    if(UserProTypec.UserPro_Type__c == 'ENG'){
                        if(productCategoriesMap.containsKey(lineList[14])){   
                            agencyReport.productCategories__c = productCategoriesMap.get(lineList[14]).productCategories__c;   
                        }
                    }
                    boolean wankeds2 = wncc(lineList[15]);
                    if(lineList[15] != null && lineList[15] != ''&&wankeds2){
                        agencyReport.warlocksNumber__c = Decimal.valueOf(lineList[15]); 
                    }
                    system.debug('lineList[16]=='+lineList[16]+'+++');  
                    String workmarkvalue=lineList[16].trim();
                    system.debug('workmarkvalue==++'+workmarkvalue+'+++');
                    if(workmarkvalue=='需要'){  
                        agencyReport.WorkMark__c =  true; 
                    }else{
                        agencyReport.WorkMark__c =  false; 
                    }
                    system.debug('agencyReport.WorkMark__c+++'+agencyReport.WorkMark__c);
                    agencyReport.WeeklyReportClassification__c = UserProTypeStr;
                    String headerStr = createHeader(week,s_agency);
                    if(agency_report_headerMap.containsKey(headerStr)){
                        agencyReport.Agency_Report_Header__c = agency_report_headerMap.get(headerStr).Id;
                    }
                    hang++;
                    arList.add(agencyReport);
                }
 
                if(errorMag != ''){
                    system.debug('errorMag==========>'+errorMag);
                    return errorMag;
                }
                // 更新经销商意愿的最新周
                if(ahlMap.values().size() > 0 ){
                    update ahlMap.values();
                }
                // 新增日报明细
                if(arList.size() > 0 ){
                    system.debug('arList==================>'+arList);
                    LightningUtil.insertMAgencyReport(arList);
                }
            }
            return 'success';  
        }catch(Exception e){
                System.debug('exception'+e);
                return e.getLineNumber()+'exception'+e;   
        }
    }
 
    // 创建唯一键
    public static String createHeader(Date s_date,String nameid){
        String str = s_date.format();
        String str1 = str.replace('/', '');
        return nameid+':'+str1;
    }
 
    // 科室对应翻译
    public static String GetDepartment_Cateogy(String department){
        String departmentE = 'no';
        if(department == '呼吸科' || department == 'BF'){
            departmentE = 'BF';
        }
        if(department == '耳鼻喉科'  || department == 'ENT'){
            departmentE = 'ENT';
        }
        if(department == 'ET耗材'  || department == 'ET'){
            departmentE = 'ET';
        }
        if(department == '消化科'  || department == 'GI'){
            departmentE = 'GI';
        }
        if(department == '普外科'  || department == 'GS'){
            departmentE = 'GS';
        }
        if(department == '妇科'  || department == 'GYN'){
            departmentE = 'GYN';
        }
        if(department == '其他'  || department == 'OTH'){
            departmentE = 'OTH';
        }
        if(department == '泌尿科'  || department == 'URO'){
            departmentE = 'URO';
        }
        return departmentE;
    }
 
    // 判断活动区分是否存在
    public static boolean GetPurposeType(String purposeType){
        Schema.DescribeFieldResult fieldResult = Agency_Report__c.WorkRecord__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        for( Schema.PicklistEntry pickListVal : ple){
            if(pickListVal.getValue() == purposeType){
                return true;
            }
        }
        return false;
    }
     // 判断效果/进度是否存在    
     public static boolean GetProductClassification(String purposeType){
        Schema.DescribeFieldResult fieldResult = Agency_Report__c.ProductClassification__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        for( Schema.PicklistEntry pickListVal : ple){
            if(pickListVal.getValue() == purposeType){
                return true;
            }
        }
        return false;
    }
 
        // 术士对应产品使用数量和科室同类耗材月使用数量验证必须数字
        public static boolean wncc(String wancco){
            Pattern pattern = Pattern.compile('^[-\\\\+]?([0-9]+\\\\.?)?[0-9]+$');
            Matcher isNum = pattern.matcher(wancco);
            if (isNum.matches() && wancco.length() <= 14) {
                return true;
            }
            return false;
        }
 
    // 判断产品区分是否满足要求
    public static String ifTrueProduct(List<Map<String,String>> prolist,String str){
        for(Map<String,String> strmap :prolist){
            if(strmap.get('label')==str){
                return strmap.get('value');
            }
        }
        return '';
    }
    // 批量添加日报by vivek end 
    //SWAG-CF58C3 fy start 
    @RemoteAction
    @AuraEnabled
    public static Map<String, String> saveAgencyContact(String name, String type,String doctorDivision1, String agencyHospitalid, String awsid) {
        //String name, String nameEncrypt, String type, String typeEncrypt, String doctorDivision1, String doctorDivision1Encrypt, String agencyHospitalid, String awsid        //zhj 新方案改造 2023-12-21
        Agency_Contact__c agency_contact = new Agency_Contact__c();
 
        agency_contact.Name = name;
        //agency_contact.Name_Encrypted__c = nameEncrypt;                           //zhj 新方案改造 2023-12-21
        agency_contact.Type__c = type;                      
        //agency_contact.Type_Encrypted__c = typeEncrypt;                           //zhj 新方案改造 2023-12-21
        agency_contact.Doctor_Division1__c = doctorDivision1;
        //agency_contact.Doctor_Division1_Encrypted__c = doctorDivision1Encrypt;    //zhj 新方案改造 2023-12-21
        agency_contact.Agency_Hospital__c = agencyHospitalid;
        agency_contact.AWS_Data_Id__c = awsid;
        
        Map<String, String> acMap = new Map<String, String>();
        
        acMap = LightningUtil.insertAgencyContact(agency_contact);
        return acMap;
    }
    //SWAG-CF58C3 fy start 
    @RemoteAction
    @AuraEnabled
    public static  List<Map<String,String>> newlyBuild(String hospital_id,String nameer, String type, String doctorDivision1){
        List<Map<String,String>> ret = new List<Map<String,String>>();
        Map<String,String> space = new Map<String,String>();
        boolean flag = false;
        space.put('label', '');
        space.put('value', '');
        space.put('selected', 'true');
        ret.add(space);
        
        // 戦略科室IDを取得して、それをもとに顧客をSELECT
        Agency_Hospital_Link__c ahl = [select Hospital__c from Agency_Hospital_Link__c where id = :hospital_id];
        List<Agency_Contact__c> doctor_list = [select id,Name,Doctor_Division1__c,Type__c,Agency_Hospital__c  
            FROM Agency_Contact__c WHERE Hospital_ID18__c=:ahl.Hospital__c order by Name];
            for(Agency_Contact__c row01 : doctor_list){
                if(row01.Name != nameer){
                    flag = true;
                }
            }
            if(flag == true){
                Agency_Contact__c acc = new Agency_Contact__c();
                acc.Name = nameer;
                acc.Type__c = type;
                acc.Doctor_Division1__c  = doctorDivision1;
                acc.Agency_Hospital__c = hospital_id;
                insert acc;
            }
            List<Agency_Contact__c> doctor_list01 = [select id,Name,Doctor_Division1__c,Type__c,Agency_Hospital__c  
            FROM Agency_Contact__c WHERE Hospital_ID18__c=:ahl.Hospital__c order by Name];
        
        for (Agency_Contact__c row : doctor_list01)
        {
            Map<String,String> tmp = new Map<String,String>();
            tmp.put('label',row.Name);
            tmp.put('value', row.Id);
            tmp.put('selected', 'false');
            tmp.put('Doctor_Division1__c', row.Doctor_Division1__c);
            ret.add(tmp);
        }
        return ret;
    }
 
    @RemoteAction
    @AuraEnabled
    public static List<Map<String,String>> selectPurposeTypes(String doctor_value){
        system.debug('doctor_value===============>'+doctor_value);
        List<FieldClassification__c> eftpcList;
        if(String.isNotBlank(doctor_value)){
            // eftpcList = [select id, Name , WorkRecord__c from EffectProgress__c where WorkRecord__c =: doctor_value];
            eftpcList = [Select Id,WorkRecord__c,EffectProgress__c from FieldClassification__c where WorkRecord__c =: doctor_value];
 
        }
        List<Map<String,String>> options = new List<Map<String,String>>();
        Map<String,String> space = new Map<String,String>();
        space.put('label', '');
        space.put('value', '');
        options.add(space);
        for(FieldClassification__c efptc : eftpcList){
            Map<String,String> efptcMap = new Map<String,String>();
            efptcMap.put('label', efptc.EffectProgress__c);
            efptcMap.put('value', efptc.EffectProgress__c);
            options.add(efptcMap);
        }
        system.debug('options===============>'+options);
        return options;
    }
    @RemoteAction
    @AuraEnabled
    public static List<Map<String,String>> selectProductClassificationc(String select_ProductClassification){
        //fy
        List<FieldClassification__c> WarlockClassificationList;
        List<AggregateResult> WarlockClassificationList2;
        User UserProTypec = LightningUtil.loginUserId();
        if(String.isNotBlank(select_ProductClassification)){
            // WarlockClassificationList = [select id, Name , ProductClassification__c from WarlockClassification__c where ProductClassification__c =: select_ProductClassification];
            if(UserProTypec.UserPro_Type__c =='ET'){
                WarlockClassificationList = [select id , ProductClassification__c,WarlockClassification__c from FieldClassification__c where ProductClassification__c =: select_ProductClassification];
            }else{
                // WarlockClassificationList2 = [select count(id) sum, Category4__c from product2 where Category3__c =: select_ProductClassification and ENG_DeaerProFlag__c  = true group by Category4__c ];
                WarlockClassificationList2 = [select count(id) sum, Category4__c from product2 where ENG_DeaerProFlag__c  = true group by Category4__c ];
            }
        }
        List<Map<String,String>> options = new List<Map<String,String>>();
        Map<String,String> space = new Map<String,String>();
        space.put('label', '');
        space.put('value', '');
        options.add(space);
        if(UserProTypec.UserPro_Type__c =='ET'){
            for(FieldClassification__c WarlockClassification : WarlockClassificationList){
                Map<String,String> WarlockClassificationMap = new Map<String,String>();
                WarlockClassificationMap.put('label', WarlockClassification.WarlockClassification__c);
                WarlockClassificationMap.put('value', WarlockClassification.WarlockClassification__c);
                options.add(WarlockClassificationMap);
            }
        }else{
            for(AggregateResult WarlockClassification2 : WarlockClassificationList2){
                Map<String,String> WarlockClassificationMap2 = new Map<String,String>();
                WarlockClassificationMap2.put('label', string.valueOf(WarlockClassification2.get('Category4__c')));
                WarlockClassificationMap2.put('value', string.valueOf(WarlockClassification2.get('Category4__c')));
                options.add(WarlockClassificationMap2);
            }
        }
        return options;
    } 
    @RemoteAction
    @AuraEnabled
    public static List<Map<String,String>> selectProductCcategory(){
        List<FieldClassification__c> ProductCcategoryList;
        User UserProETENG = LightningUtil.loginUserId();
        if(UserProETENG.UserPro_Type__c == 'ET'){
            ProductCcategoryList = [select id,  ProductCcategory__c from FieldClassification__c where classification__c =: 'ET'];
        }else{
            ProductCcategoryList = [select id,  ProductCcategory__c from FieldClassification__c where classification__c =: 'ENG'];
        }
        List<Map<String,String>> options = new List<Map<String,String>>();
        Map<String,String> space = new Map<String,String>();
        space.put('label', '');
        space.put('value', '');
        options.add(space);
        for(FieldClassification__c ProductCcategory : ProductCcategoryList){
            Map<String,String> ProductCcategorynMap = new Map<String,String>();
            ProductCcategorynMap.put('label', ProductCcategory.ProductCcategory__c);
            ProductCcategorynMap.put('value', ProductCcategory.ProductCcategory__c);
            options.add(ProductCcategorynMap);
        }
        return options;
    }
    @RemoteAction
    @AuraEnabled
    public static List<Map<String,String>> selectProductCcategory01(String select_ProductCcategory){
        List<FieldClassification__c> productCategoriesList;
        User UserProETENG = LightningUtil.loginUserId();
        System.debug('UserProETENG.UserPro_Type__c=============>'+UserProETENG.UserPro_Type__c);
        System.debug('select_ProductCcategory=============>'+select_ProductCcategory);
        FieldClassification__c fi = [Select ProductCcategory__c from FieldClassification__c where ProductCcategory__c =: select_ProductCcategory limit 1];
        if(UserProETENG.UserPro_Type__c == 'ET'){
            productCategoriesList = [select id, productCategories__c,ET_ENG_classification__c,ProductCcategory__c from FieldClassification__c where ProductCcategory__c =: fi.ProductCcategory__c AND ET_ENG_classification__c =: 'ET'];
        }else{
            productCategoriesList = [select id, productCategories__c,ET_ENG_classification__c,ProductCcategory__c from FieldClassification__c where ProductCcategory__c =:fi.ProductCcategory__c AND ET_ENG_classification__c =: 'ENG'];
        }
        List<Map<String,String>> options = new List<Map<String,String>>();
        Map<String,String> space = new Map<String,String>();
        space.put('label', '');
        space.put('value', '');
        options.add(space);
        for(FieldClassification__c productCategories : productCategoriesList){
            Map<String,String> productCategoriesMap = new Map<String,String>();
            productCategoriesMap.put('label', productCategories.productCategories__c);
            productCategoriesMap.put('value', productCategories.productCategories__c);
            options.add(productCategoriesMap);
        }
        System.debug('options=============>'+options);
        return options;
    }
    //zhj MEBG新方案改造 2022-11-29 start
    @AuraEnabled
    public static ControllerResponse searchAgencyDataId(String hospitalId){
        ControllerResponse r = new ControllerResponse();
        try{
            if(String.isBlank(hospitalId)){
                r.IsSuccess = true;
                r.Message = 'noHospitalId';
                return r;
            }
            List<Agency_Contact__c> acList = [select id,AWS_Data_Id__c,Agency_Hospital__r.Name from Agency_Contact__c where Agency_Hospital__c=:hospitalId];
            r.IsSuccess = true;
            r.Message = '';
            r.Data = acList;
            return r;
        }catch(Exception e) {
            System.debug('into catch'+e.getMessage());
            r.IsSuccess = false;
            r.message = e.getMessage()+e.getStackTraceString();
            return r;
        }
    }
    public static void improveTestRate(){
        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++;
    }
    //zhj MEBG新方案改造 2022-11-29 end
}