高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
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
public with sharing class CheckAllOlympusAssetController {
    public static Asset StaticAssetQuertResult;
    // 按钮区域
    public String assertQueryCondition {get; private set;}
    public Boolean allBlueFlag {get; private set;}  // 查看全部保有设备蓝色按钮Flag
    public Boolean consumableBlueFlag {get; private set;}  // 查看在库的保有设备蓝色按钮Flag
    public Boolean lendingBlueFlag {get; private set;}  // 查看出借中保有设备蓝色按钮Flag
    public Boolean repairingBlueFlag {get; private set;}  // 查看修理中保有设备蓝色按钮Flag
    public Boolean scrappingBlueFlag {get; private set;}  // 查看待报废保有设备蓝色按钮Flag
    public Boolean scrappedBlueFlag {get; private set;}  //查看已报废保有设备蓝色按钮Flag
    public Boolean consumedBlueFlag {get; private set;}  //查看已消耗的保有设备
    public Boolean soonExpiredBlueFlag {get; private set;} //查看即将到期的保有设备
    public Boolean expiredBlueFlag {get; private set;}  //查看已过期的保有设备
 
    public Boolean angecylookrole {get; private set;} //办事处查看权限 20210628 you 1650
    // 检索区域
    public static final String NONE = system.label.StartTrading_None;  // 「なし」ラベル [Chinese:--无--]
    public String internalAssetLocation;  // 后台使用的
    public String internalAssetLocationLogin {get; set;}  // login的备品存放地
    public String internalAssetLocationSet {get; set;}  // 备品存放地 Internal_asset_location__c
    public String beipinCunFangDi {get; set;}  // 备品存放地
 
    public SearchBean searchB {get; set;} // 检索用Bean
 
    // 备品存放地 检索条件设置区
    public List<SelectOption> internalAssetLocationOptionList {
        get {
            if (internalAssetLocationOptionList == null) {
                internalAssetLocationOptionList = getPlickList('Asset', 'Internal_asset_location__c');
            }
            return internalAssetLocationOptionList;
        }
        set;
    }
 
    // 备品存放地 数据适用区
    public List<SelectOption> internalAssetDataLocationOptionList {
        get {
            if (internalAssetDataLocationOptionList == null) {
                internalAssetDataLocationOptionList = getPlickList('Asset', 'Internal_asset_location__c');
            }
            return internalAssetDataLocationOptionList;
        }
        set;
    }
 
    public String assetStatus {get; set;}  // 备品状态 Asset_Status__c 左侧快捷按钮
    public String assetStatus1 {get; set;}  // 备品状态 Asset_Status__c 右侧检索区的
    public List<SelectOption> assetStatusOptionList {
        get {
            // FIXME StartTrading_None を使う、--なし-- はNGでしょう
            List<SelectOption> selectOptions = new List<SelectOption> { new SelectOption(NONE, NONE) };
            //无保有
            selectOptions.add(new SelectOption(FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Wu_Bao_You.ordinal()), FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Wu_Bao_You.ordinal())));
            //无库存
            selectOptions.add(new SelectOption(FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Mei_You_Ku_Cun.ordinal()), FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Mei_You_Ku_Cun.ordinal())));
            //可分配
            selectOptions.add(new SelectOption(FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Ke_Yi_Fen_Pei.ordinal()), FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Ke_Yi_Fen_Pei.ordinal())));
            //暂定分配
            selectOptions.add(new SelectOption(FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Zan_Ding_Fen_Pei.ordinal()), FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Zan_Ding_Fen_Pei.ordinal())));
            //已出库指示
            selectOptions.add(new SelectOption(FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Yi_Chu_Ku_Zhi_Shi.ordinal()), FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Yi_Chu_Ku_Zhi_Shi.ordinal())));
            //已下架
            selectOptions.add(new SelectOption(FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Yi_Xia_Jia.ordinal()), FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Yi_Xia_Jia.ordinal())));
            //出库前已检测
            selectOptions.add(new SelectOption(FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Chu_Ku_Qian_Yi_Jian_Ce.ordinal()), FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Chu_Ku_Qian_Yi_Jian_Ce.ordinal())));
            //已出库
            selectOptions.add(new SelectOption(FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Yi_Chu_Ku.ordinal()), FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Yi_Chu_Ku.ordinal())));
            //申请者已收货
            selectOptions.add(new SelectOption(FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Shen_Qing_Zhe_Yi_Shou_Huo.ordinal()), FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Shen_Qing_Zhe_Yi_Shou_Huo.ordinal())));
            //申请者收货NG
            selectOptions.add(new SelectOption(FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Shen_Qing_Zhe_Shou_Huo_NG.ordinal()), FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Shen_Qing_Zhe_Shou_Huo_NG.ordinal())));
            //医院已装机确认
            selectOptions.add(new SelectOption(FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Yi_Yuan_Yi_Zhuang_Ji_Que_Ren.ordinal()), FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Yi_Yuan_Yi_Zhuang_Ji_Que_Ren.ordinal())));
            //已回寄
            selectOptions.add(new SelectOption(FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Yi_Hui_Ji.ordinal()), FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Yi_Hui_Ji.ordinal())));
            //欠品中
            selectOptions.add(new SelectOption(FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Qian_Pin_Zhong.ordinal()), FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Qian_Pin_Zhong.ordinal())));
            //已回收
            selectOptions.add(new SelectOption(FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Yi_Hui_Shou.ordinal()), FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Yi_Hui_Shou.ordinal())));
            //回收后已CDS
            selectOptions.add(new SelectOption(FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Hui_Shou_Hou_Yi_CDS.ordinal()), FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Hui_Shou_Hou_Yi_CDS.ordinal())));
            //待上架
            selectOptions.add(new SelectOption(FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Dai_Shang_Jia.ordinal()), FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Dai_Shang_Jia.ordinal())));
            //待移至报废区
            selectOptions.add(new SelectOption(FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Yi_Zhi_Bao_Fei_Qu.ordinal()), FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Yi_Zhi_Bao_Fei_Qu.ordinal())));
            //待废弃
            selectOptions.add(new SelectOption(FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Dai_Fei_Qi.ordinal()), FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Dai_Fei_Qi.ordinal())));
            //废弃
            selectOptions.add(new SelectOption(FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Fei_Qi.ordinal()), FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Fei_Qi.ordinal())));
            //修理草案中
            selectOptions.add(new SelectOption(FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Xiu_Li_Cao_An_Zhong.ordinal()), FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Xiu_Li_Cao_An_Zhong.ordinal())));
            //修理中
            selectOptions.add(new SelectOption(FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Xiu_Li_Zhong.ordinal()), FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Xiu_Li_Zhong.ordinal())));
            //冻结
            selectOptions.add(new SelectOption(FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Dong_Jie.ordinal()), FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Dong_Jie.ordinal())));
            //丢失
            selectOptions.add(new SelectOption(FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Diu_Shi.ordinal()), FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Diu_Shi.ordinal())));
 
            return selectOptions;
        }
    }
    public List<SelectOption> bodyOrAccessoryOptionList {
        get {
            List<SelectOption> selectOptions = new List<SelectOption> { new SelectOption(NONE, NONE) };
            //主体
            selectOptions.add(new SelectOption('主体', '主体'));
            //附属品
            selectOptions.add(new SelectOption('附属品', '附属品'));
 
            return selectOptions;
        }
    }
    //public String limits {get; set;}
    public List<SelectOption> limitOpts {
        get {
            //List<SelectOption> limitOpts = new List<SelectOption> { new SelectOption(NONE, NONE) };
            List<SelectOption> limitOpts = new List<SelectOption>();
            //limitOpts.add(new SelectOption('2','2'));
            limitOpts.add(new SelectOption('10','10'));
            limitOpts.add(new SelectOption('50','50'));
            limitOpts.add(new SelectOption('100','100'));
            limitOpts.add(new SelectOption('200','200'));
 
            return limitOpts;
        }
    }
 
    // 分公司号PlickList
    public List<SelectOption> companyOfEquipmentOpts {
        get {
            if (companyOfEquipmentOpts == null) {
                companyOfEquipmentOpts = getPlickList('Asset', 'CompanyOfEquipment__c');
            }
            return companyOfEquipmentOpts;
        }
        set;
    }
 
    //  产品分类PlickList
    public List<SelectOption> product_categoryOpts {
        get {
            if (product_categoryOpts == null) {
                product_categoryOpts = getPlickList('Asset', 'Product_category__c');
            }
            return product_categoryOpts;
        }
        set;
    }
 
    // 备品分类PlickList
    public List<SelectOption> equipment_TypeOpts {
        get {
            if (equipment_TypeOpts == null) {
                equipment_TypeOpts = getPlickList('Asset', 'Equipment_Type__c');
            }
            return equipment_TypeOpts;
        }
        set;
    }
 
    // 管理种类PlickList
    public List<SelectOption> manage_typeOpts {
        get {
            if (manage_typeOpts == null) {
                manage_typeOpts = getPlickList('Asset', 'Manage_type__c');
            }
            return manage_typeOpts;
        }
        set;
    }
 
    // 所在地区(本部)PlickList
    public List<SelectOption> salesdepartmentOpts {
        get {
            if (salesdepartmentOpts == null) {
                salesdepartmentOpts = getPlickList('Asset', 'Salesdepartment__c');
            }
            return salesdepartmentOpts;
        }
        set;
    }
 
    // 所在地区(省)PlickList
    public List<SelectOption> salesProvinceOpts {
        get {
            if (salesProvinceOpts == null) {
                salesProvinceOpts = getPlickList('Asset', 'SalesProvince__c');
            }
            return salesProvinceOpts;
        }
        set;
    }
    // 备品类别PlickList
    public List<SelectOption> assetLoanerCategoryOpts {
        get {
            if(assetLoanerCategoryOpts == null){
                assetLoanerCategoryOpts = new List<SelectOption>();
                assetLoanerCategoryOpts.add(new SelectOption('', NONE));
                assetLoanerCategoryOpts.add(new SelectOption('备品', '备品'));
                assetLoanerCategoryOpts.add(new SelectOption('耗材', '耗材'));
            }
            return assetLoanerCategoryOpts;
        }
        set;
    }
    // 到期时间picklist
    public List<SelectOption> daysToExpiredOpts {
        get {
            if(daysToExpiredOpts == null){
                daysToExpiredOpts = new List<SelectOption>();
                daysToExpiredOpts.add(new SelectOption('', NONE));
                daysToExpiredOpts.add(new SelectOption('7', '一周内到期'));
                daysToExpiredOpts.add(new SelectOption('14', '两周内到期'));
            }
            return daysToExpiredOpts;
        }
        set;
    }
 
    private String targetColumusStr;  // SOQL中的检索列
 
    // 项目set 字段标签
    public List<String> leftLabelList {get; private set;}
    public List<String> rightLabelList {get; private set;}
    public List<String> allLabelList {get; private set;}
    public Integer leftLabelSize {
        get {
            return leftLabelList.size();
        }
    }
    // 项目set 字段名
    public List<List<String>> leftApiList {get; private set;}  // 参照項目用
    public List<List<String>> rightApiList {get; private set;}  // 参照項目用
    public List<String> allApiList {get; private set;}  // 参照項目用
    public Integer eachLineSize {get; set;}
    public List<String> apiTypeIsReferenceList {get; set;}  // 判断api是否为参照关系
 
    public List<String> columnLeftCssList {get; private set;}  // css 用
    public List<String> columnRightCssList {get; private set;}  // css 用
    public Map<String, String> columnLeftRWMap {get; private set;}  // r,w,wm用
    public Map<String, String> columnRightRWMap {get; private set;}  // r,w,wm用
    private Map<String, String> DESC_RW = null;
    public String setInternalAssetLocation {get; set;}  // 设置备品存放地
    public String setAssetType {get; set;}  // 设置备品分类
    public List<String> canChangeFlagList {get; set;}  // 是否可编辑
    public String isSavingSuccess {get; set;}  // 保存flag
    public Asset assetSetting {get; set;}  // 设置用
    public List<Asset> allAssetDataList {get; set;}  // 明细结果(不包括checkoutbox)
    public Integer getAllAssetDataListSize() {  // 明细条数
        return allAssetInfoList.size();
    }
    public List<AssetInfo> allAssetInfoList {get; set;}  // 明细结果(包括checkoutbox)
    public List<Asset> assetExportCsvList {get; set;}  // 明细结果(导出CSV)
    public List<List<String>> exportCsvResultList {get; set;}
 
    public String changeFlg {get; set;}  // 监视刷新画面前是否存在未保持的值
    public Boolean searchFromBtn {get; private set;}  // 是否来自快捷键进行检索
    public Boolean searchFromSave {get; private set;}  // 是否来自保存进行检索
    public Boolean onlyReadFlag {get; set;}  // 只读权限
    public Boolean returnFirstPageFlag {get; private set;}  // 返回首页
    public Boolean beipincunfangdiEditableFlag {get; private set;}  // 备品存放地权限
    public Boolean beipinfenleiEditableFlag {get; private set;}  // 备品分类权限
 
    public Boolean equipmentSetManagmentCodeEditableFlag {get; private set;}  // 备品管理编码权限
    public Boolean internalAssetNumberEditableFlag {get; private set;}  // 固定资产号权限
    public Boolean serialNumberEditableFlag {get; private set;}  // 机身号权限
    public Boolean companyEquipmentEditableFlag {get; private set;}  // 分公司号权限
    public Boolean productCategoryEditableFlag {get; private set;}  // 产品分类权限
    public Boolean manageTypeEditableFlag {get; private set;}  // 管理种类权限
    public Boolean salesDepartmentEditableFlag {get; private set;}  // 所在地区(本部)
    public Boolean salesProvinceEditableFlag {get; private set;}  // 所在地区(省)
    public Boolean consumableGuaranteenEndEditableFlag {get; private set;}  // 消耗品有效期至
    public Boolean excess2000Flag {get; set;}  // 判断超过2000
 
    public Date consumableGuaranteenEndDate {get; set;}  // 消耗品有效期至 (2B2无access权限时)
 
    // 排序用
    public String sortKey {get; set;}
    public String preSortKey {get; set;}
    public Boolean sortOrderAsc {get; set;}
    public List<String> sortOrderList {get; set;}
    public Integer totalSoqlRecordNum {get; set;}  // 总数据数量
    public Integer totalNum {get; set;}  // 检索出的总数量 = 检索出的数量 + 打勾固定的数量
    // 分页用
    public String selRecordOption { get; set; }  // 选择的每页记录数
    public Integer selctRecordNum { get { return Integer.valueOf(selRecordOption); } } // 选择的每页记录数
    public Integer currPage { get; set; }  // 当前页
    public Integer totalPage { get; set; }  // 总页数
    public Integer totalFixDataNum { get; set; }  // 打勾固定数据数量
    public Integer totalUnfixDataNum { get; set; }  // 未打勾固定数据数量
    public List<User> loginUserList { get; set; }
    public String fromQuickBarFlag;  // 是否来自导航区按钮检索
    public static String assetRecordTypeId = System.Label.Asset_RecordType;
 
    public Asset getAsset() {  // 临时使用
        if (StaticAssetQuertResult == null) {
            StaticAssetQuertResult = new Asset(Id =
                [SELECT Id
                   FROM Asset
                  WHERE Asset_Owner__c = 'Olympus'
                    AND RecordTypeId = :assetRecordTypeId
                    // AND RecordTypeId = '01210000000kOPRAA2'
                    // AND Equipment_Type__c != '检测用备品' 已QA 不需要增加条件
                    AND Delete_Flag__c = False
                  LIMIT 1 ].Id);
        }
        System.debug('StaticAssetQuertResult.Id1===' + StaticAssetQuertResult.Id);
        return new Asset(Id = StaticAssetQuertResult.Id, RecordTypeId = assetRecordTypeId);
    }
 
    public String appliedSelectOption {get; set;}
 
    public String exportCsvName {get; set;}
    public Integer checkedAssetInfoNum {get; set;}
    public String checkFromQuickBarFlag;
 
    // 明细类
    class AssetInfo {
        public Boolean isCheck {get; set;}  // 是否选择
        public Asset assetQuertResult {get; set;}  // 借出备品set一览
        public AssetInfo() {
            isCheck = false;
            if (StaticAssetQuertResult == null) {
                StaticAssetQuertResult = new Asset(Id =
                  [SELECT Id
                     FROM Asset
                    WHERE Asset_Owner__c = 'Olympus'
                      AND RecordTypeId = :assetRecordTypeId
                      // AND RecordTypeId = '01210000000kOPRAA2'
                      // AND Equipment_Type__c != '检测用备品' 已QA 不需要增加条件
                      AND Delete_Flag__c = False
                    LIMIT 1 ].Id);
            }
            System.debug('StaticAssetQuertResult.Id2===' + StaticAssetQuertResult.Id);
            assetQuertResult = new Asset(Id = StaticAssetQuertResult.Id, RecordTypeId = assetRecordTypeId);
        }
    }
    // 导出CSV
    public String COMMA {
        get {
            return Parser.COMMA;
        }
    }
    public String CRLF {
        get {
            return Parser.CRLF;
        }
    }
 
 
    public CheckAllOlympusAssetController() {
        currPage = 1;
        selRecordOption = '10';  // 初始化时默认选择数量
        totalNum = 0;
        // 备品的RecordTypeId = 01210000000kOPRAA2
        DESC_RW = SoapApi.getEditLayoutItemRW('Asset', new String[]{System.Label.Asset_RecordType}).get(System.Label.Asset_RecordType);
    }
    public CheckAllOlympusAssetController(ApexPages.StandardController controller) {
        currPage = 1;
        selRecordOption = '10';  // 初始化时默认选择数量
        totalNum = 0;
        DESC_RW = SoapApi.getEditLayoutItemRW('Asset', new String[]{System.Label.Asset_RecordType}).get(System.Label.Asset_RecordType);
    }
 
    // 画面初始化
    public void init() {
        searchB = new SearchBean();
        System.debug('Start init');
        isSavingSuccess = 'true';
        checkFromQuickBarFlag = 'false';
        checkedAssetInfoNum = 0;
        bp3_Setting__c bp3config = bp3_Setting__c.getOrgDefaults();
        fromQuickBarFlag = 'false';
 
        exportCsvName = bp3config.Export_CSV_Filename__c + datetime.now().format('_YYYY-MM-dd_') + UserInfo.getUserName().split('@')[0] + '.csv';  // CustomSet的CSV文件名 日期 登录者Username
        System.debug('exportCsvName === ' + exportCsvName);
        System.debug('UserInfo.getUserId()===' + UserInfo.getUserName().split('@')[0]);
 
        appliedSelectOption = '';
        changeFlg = '0';
        searchFromBtn = false;
        onlyReadFlag = false;
        searchFromSave = false;
        initSearchButtonColor();
        returnFirstPageFlag = true;
        excess2000Flag = false;
        assetSetting = getAsset();
        System.debug('assetSetting.Equipment_Type__c ==' + assetSetting.Equipment_Type__c);
        allAssetDataList = new List<Asset>();
        allAssetInfoList = new List<AssetInfo>();
        //setAssetFieldSetInfo();
        totalFixDataNum = 0;
        totalUnfixDataNum =0;
        // 权限
        beipincunfangdiEditableFlag = Schema.sObjectType.Asset.fields.getMap().get('Internal_asset_location__c').getDescribe().isUpdateable();
        beipinfenleiEditableFlag = Schema.sObjectType.Asset.fields.getMap().get('Equipment_Type__c').getDescribe().isUpdateable();
        // 备品管理编码权限
        equipmentSetManagmentCodeEditableFlag = Schema.sObjectType.Asset.fields.getMap().get('EquipmentSet_Managment_Code__c').getDescribe().isUpdateable();
        // 固定资产号权限
        internalAssetNumberEditableFlag = Schema.sObjectType.Asset.fields.getMap().get('Internal_Asset_number__c').getDescribe().isUpdateable();
        // 机身号权限
        serialNumberEditableFlag = Schema.sObjectType.Asset.fields.getMap().get('SerialNumber').getDescribe().isUpdateable();
        // 分公司号权限
        companyEquipmentEditableFlag = Schema.sObjectType.Asset.fields.getMap().get('CompanyOfEquipment__c').getDescribe().isUpdateable();
        // 产品分类权限
        productCategoryEditableFlag = Schema.sObjectType.Asset.fields.getMap().get('Product_category__c').getDescribe().isUpdateable();
        // 管理种类权限
        manageTypeEditableFlag = Schema.sObjectType.Asset.fields.getMap().get('Manage_type__c').getDescribe().isUpdateable();
        // 所在地区(本部)
        salesDepartmentEditableFlag = Schema.sObjectType.Asset.fields.getMap().get('Salesdepartment__c').getDescribe().isUpdateable();
        // 所在地区(省)
        salesProvinceEditableFlag = Schema.sObjectType.Asset.fields.getMap().get('SalesProvince__c').getDescribe().isUpdateable();
        // 消耗品有效期至
        consumableGuaranteenEndEditableFlag = Schema.sObjectType.Asset.fields.getMap().get('Consumable_Guaranteen_end__c').getDescribe().isUpdateable();
        System.debug('7777');
        //loginUserList = new List<User>();
        loginUserList = [SELECT Id, Default_Referable_Apply_Equipment_Center__c
                         FROM User
                         WHERE Id = :Userinfo.getUserId()];
        beipinCunFangDi = loginUserList[0].Default_Referable_Apply_Equipment_Center__c;  // User.默认可参照备品中心
 
        //办事处查看权限  20210628 you 1650
        if (beipinCunFangDi=='广州 备品中心' || beipinCunFangDi=='北京 备品中心' || beipinCunFangDi=='上海 备品中心') {
            angecylookrole =true;
        }
        setAssetFieldSetInfo();//20210628 1650 you 挪个位置
        if (UserInfo.getProfileId() == System.Label.ProfileId_SystemAdmin || System.Label.ProfileId_EquCenAdmin.contains(UserInfo.getProfileId())) {
            internalAssetLocationLogin = FixtureUtil.bieCunFangDiOpsMap.get('备品管理中心')[0].getValue();  // SelectOption('All', '--全部--')
        } else {
            List<SelectOption> tempBieCunFangDiOpsList = FixtureUtil.bieCunFangDiOpsMap.get('备品管理中心');
            internalAssetLocationLogin = beipinCunFangDi;  // User.默认可参照备品中心
        }
        //internalAssetLocation1 = internalAssetLocationLogin;
        System.debug('internalAssetLocationLogin1111===' + internalAssetLocationLogin);
 
        System.debug('beipinCunFangDi===' + beipinCunFangDi);
 
        checkAssetBtn();
    }
    public void setAssetFieldSetInfo() {
        leftLabelList = new List<String>();
        rightLabelList = new List<String>();
        allLabelList = new List<String>();
 
        leftApiList = new List<List<String>>();
        rightApiList = new List<List<String>>();
        allApiList = new List<String>();
 
        columnLeftCssList = new List<String>();
        columnRightCssList = new List<String>();
        columnLeftRWMap = new Map<String, String>();
        columnRightRWMap = new Map<String, String>();
        List<String> columnLeftFieldPathList = new List<String>();
        List<String> columnRightFieldPathList = new List<String>();
        // 获得納入商品 項目セット
        Map<String, Schema.FieldSet> assetFieldSetMap = Schema.getGlobalDescribe().get('Asset').getDescribe().fieldSets.getMap();
        // 項目セット查看保有设备_左侧固定
        Schema.FieldSet leftFieldSetSet = assetFieldSetMap.get('CheckAsset_LeftFix');
        // 項目セット查看保有设备_右侧固定
        Schema.FieldSet rightFieldSetSet;
        //20210628 you 1650 办事处不显示 货架号
        system.debug('zheli'+angecylookrole);
        if(angecylookrole){
           rightFieldSetSet  = assetFieldSetMap.get('CheckAsset_Right');  
        } else{
           rightFieldSetSet = assetFieldSetMap.get('CheckAsset_Right_Angecy'); 
        }
        // 获得左侧固定項目セット中的所有项目
        List<FieldSetMember> leftFieldSetMemberList = leftFieldSetSet.getFields();
        // 获得右侧項目セット中的所有项目
        List<FieldSetMember> rightFieldSetMemberList = rightFieldSetSet.getFields();
        Boolean haveWrongField = false;
        for (FieldSetMember eachLeftFieldSetMember : leftFieldSetMemberList) {
            List<String> splitLeftFieldPathList = eachLeftFieldSetMember.getFieldPath().split('\\.');  // List size > 1 对应关联表
            if (splitLeftFieldPathList.size() > 1) {
                if ( haveWrongField == false) {
                     ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.WARNING, '保有设备字段集CheckAsset_LeftFix只能选择保有设备的字段'));
                     haveWrongField = true;
                }
                continue;
            }
            leftLabelList.add(eachLeftFieldSetMember.getLabel());  // 左侧項目セットLabel
            columnLeftFieldPathList.add(eachLeftFieldSetMember.getFieldPath());  // 左侧項目セットAPI
            leftApiList.add(splitLeftFieldPathList);  // List<List<String>>() 左侧項目セットAPI
            if (DESC_RW == null) {
                columnLeftRWMap.put(eachLeftFieldSetMember.getFieldPath(), 'r');  // 未设置,默认为只读
            } else if (splitLeftFieldPathList.size() == 1) {
                String rw = DESC_RW.get(eachLeftFieldSetMember.getFieldPath());
                if (rw != null) {
                    columnLeftRWMap.put(eachLeftFieldSetMember.getFieldPath(), rw);  // 可读可写
                } else {
                    columnLeftRWMap.put(eachLeftFieldSetMember.getFieldPath(), 'r');  // 只读
                }
            } else {
                columnLeftRWMap.put(eachLeftFieldSetMember.getFieldPath(), 'r');  // 只读
            }
        }
 
        for (String eachColumnLeftFieldPath : columnLeftFieldPathList) {
        //    if (queryColumusSet.contains(eachcolumnLeftFieldPath) == false) {
        //        queryColumus.add(eachcolumnLeftFieldPath);
        //        queryColumusSet.add(eachcolumnLeftFieldPath);
        //    }
            columnLeftCssList.add(eachcolumnLeftFieldPath.replace('.', '_'));  // 与API相同
        }
        // 項目セット查看保有设备_右侧可拖动
        for (FieldSetMember eachRightFieldSetMember : rightFieldSetMemberList) {
            List<String> splitRightFieldPathList = eachRightFieldSetMember.getFieldPath().split('\\.');  // 与上面的相同
            if (splitRightFieldPathList.size() > 1) {
                if ( haveWrongField == false) {
                     ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.WARNING, '保有设备字段集CheckAsset_Right只能选择保有设备的字段'));
                     haveWrongField = true;
                }
                continue;
            }
            rightLabelList.add(eachRightFieldSetMember.getLabel());  // 左侧項目セットLabel
            columnRightFieldPathList.add(eachRightFieldSetMember.getFieldPath());  // 左侧項目セットAPI
            rightApiList.add(splitRightFieldPathList);  // List<List<String>>() 左侧項目セットAPI
            if (DESC_RW == null) {
                columnRightRWMap.put(eachRightFieldSetMember.getFieldPath(), 'r');  // 未设置,默认为只读
            } else if (splitRightFieldPathList.size() == 1) {
                String rw = DESC_RW.get(eachRightFieldSetMember.getFieldPath());
                if (rw != null) {
                    columnRightRWMap.put(eachRightFieldSetMember.getFieldPath(), rw);  // 可读可写
                } else {
                    columnRightRWMap.put(eachRightFieldSetMember.getFieldPath(), 'r');  // 只读
                }
            } else {
                columnRightRWMap.put(eachRightFieldSetMember.getFieldPath(), 'r');  // 只读
            }
        }
 
        for (String eachColumnRightFieldPath : columnRightFieldPathList) {
            columnRightCssList.add(eachcolumnRightFieldPath.replace('.', '_'));  // 与API相同
        }
 
        allLabelList.addAll(leftLabelList);
        allLabelList.addAll(rightLabelList);
        System.debug('allLabelList=====' + allLabelList);  // 备品存放地, 所在地区(本部), 所在地区(省), 备品配套明细型号, 设备名, 固定资产编号(Key), 固定资产编号, 产品 + 机体编码, 产品分类(GI/SP), 备品分类, ...
        for (List<String> eachApiList : leftApiList) {
            allApiList.add(eachApiList[0]);
        }
        for (List<String> eachApiList : rightApiList) {
            allApiList.add(eachApiList[0]);
        }
        // CSV 每一行数量 不包括Id
        if (allApiList.contains('Id')) {
            allApiList.remove(0);
        }
        eachLineSize = allApiList.size();
        System.debug('allApiList===' + allApiList);
        Map<String, Schema.SObjectField> objectFields = Schema.getGlobalDescribe().get('Asset').getDescribe().fields.getMap();
        for(String eachApi : allApiList) {
            Schema.DescribeFieldResult lfieldLabel = objectFields.get(eachApi).getDescribe();
            Schema.DisplayType dType = lfieldLabel.getType();
            if (String.ValueOf(dType) == 'REFERENCE') {
                apiTypeIsReferenceList.add(eachApi);
            }
        }
 
 
 
        Map<String, SObjectField> queryAssetFieldMap = Asset.getSObjectType().getDescribe().fields.getMap();
        canChangeFlagList = new List<String>();
        for (String eachApi : allApiList) {
            DescribeFieldResult queryAssetFieldResult = queryAssetFieldMap.get(eachApi).getDescribe();
            if (!queryAssetFieldResult.isCalculated()) {
                canChangeFlagList.add('');
            } else {
                canChangeFlagList.add('(不可修改)');
            }
        }
        targetColumusStr = String.join(allApiList, ', ');
        if (targetColumusStr.contains('LastModifiedDate') == false) {
            targetColumusStr += ', LastModifiedDate';
        }
 
        // 默认排序
        this.sortKey = '0';
        this.preSortKey = '0';
        this.sortOrderAsc = true;
        this.sortOrderList = new List<String>();
        this.sortOrderList.add('↑');
        for (Integer i = 0; i < allLabelList.size(); i++) {
            this.sortOrderList.add(' ');
        }
    }
 
    // 初始化按钮颜色
    public void initSearchButtonColor() {
        angecylookrole =false; //20210628 you 1650
        allBlueFlag = true;  // 初始页面上全部保有设备按钮为蓝色
        consumableBlueFlag = false;
        lendingBlueFlag = false;
        repairingBlueFlag = false;
        scrappingBlueFlag = false;
        scrappedBlueFlag = false;
        consumedBlueFlag = false;
        soonExpiredBlueFlag = false;
        expiredBlueFlag = false;
    }
    // 检索按钮 查看保有设备
    public void checkAssetBtn() {
        // get方式传url参数
        if (String.isBlank(assertQueryCondition)) {
            assertQueryCondition = ApexPages.currentPage().getParameters().get('searchType');
        }
        System.debug('ApexPages.currentPage().getParameters().searchType===' + assertQueryCondition);
        // 来自按钮
        String tempAssertQueryCondition = ApexPages.currentPage().getParameters().get('assertCondition');
        System.debug('ApexPages.currentPage().getParameters()tempAssertQueryCondition===' + tempAssertQueryCondition);
        String fromQuickBarFlag = ApexPages.currentPage().getParameters().get('fromQuickBarFlag');
        System.debug('ApexPages.currentPage().getParameters()fromQuickBarFlag===' + fromQuickBarFlag);
        checkFromQuickBarFlag = fromQuickBarFlag;
        if (String.isNotBlank(tempAssertQueryCondition)) {
            assertQueryCondition = tempAssertQueryCondition;
        }
        //initSearchButtonColor();  // 每次检索时初始化按钮颜色
        //searchFromBtn = true;  // 去掉打钩项
        if (String.isNotBlank(assertQueryCondition) && assertQueryCondition != null) {
            System.debug('changecolor');
            allBlueFlag = false;
            consumableBlueFlag = false;
            lendingBlueFlag = false;
            repairingBlueFlag = false;
            scrappingBlueFlag = false;
            scrappedBlueFlag = false;
            consumedBlueFlag = false;
            soonExpiredBlueFlag = false;
            expiredBlueFlag = false;
            if (assertQueryCondition == 'all') {  //  备品检索条件assertQueryCondition为空视为 查看全部保佑设备
                allBlueFlag = true;
            } else if (assertQueryCondition == 'consumable') {
                consumableBlueFlag = true;
            } else if (assertQueryCondition == 'lending') {
                lendingBlueFlag = true;
            } else if (assertQueryCondition == 'repairing') {
                repairingBlueFlag = true;
            } else if (assertQueryCondition == 'scrapping') {
                scrappingBlueFlag = true;
            } else if (assertQueryCondition == 'scrapped') {
                scrappedBlueFlag = true;
            } else if (assertQueryCondition == 'consumed') {
                consumedBlueFlag = true;
            } else if (assertQueryCondition == 'soonExpired') {
                soonExpiredBlueFlag = true;
            } else if (assertQueryCondition == 'expired') {
                expiredBlueFlag = true;
            }
        }
        System.debug('fromQuickBarFlag1===' + fromQuickBarFlag);
        searchBtn();
    }
 
    // 适用
    public List<SelectOption> getAppliedSelectOptionList() {
        if (allApiList.contains('Id')) {
            allApiList.remove(0);
        }
        if (allLabelList.contains('Id')) {
            allLabelList.remove(0);
        }
 
        Map<String, Schema.FieldSet> assetFieldSetMap = Schema.getGlobalDescribe().get('Asset').getDescribe().fieldSets.getMap();
        Schema.FieldSet appliedFieldSetSet = assetFieldSetMap.get('CheckAsset_Apply');
        List<FieldSetMember> appliedFieldSetMemberList = appliedFieldSetSet.getFields();
        List<String> appliedLabelList = new List<String>();
        System.debug('appliedLabelList===' + appliedLabelList);
        System.debug('appliedFieldSetMemberList===' + appliedFieldSetMemberList);
        for (FieldSetMember eachAppliedFieldSetMember : appliedFieldSetMemberList) {
            System.debug('eachAppliedFieldSetMember===' + eachAppliedFieldSetMember);
            //String targetAppliedApi = allApiList.get(allLabelList.indexOf(eachAppliedFieldSetMember.getLabel()));
            String targetAppliedApi = '';
            system.debug('zheli0'+allLabelList.indexOf(eachAppliedFieldSetMember.getLabel()));
            if(allLabelList.indexOf(eachAppliedFieldSetMember.getLabel())!=-1){ //不包含
                targetAppliedApi =allApiList.get(allLabelList.indexOf(eachAppliedFieldSetMember.getLabel()));
                System.debug('targetAppliedApi===' + targetAppliedApi);
                if (Schema.sObjectType.Asset.fields.getMap().get(targetAppliedApi).getDescribe().isUpdateable()) {
                    System.debug('targetAppliedApi111===' + targetAppliedApi);
                    appliedLabelList.add(eachAppliedFieldSetMember.getLabel());
                }
            }
           
        }
        List<SelectOption> appliedSelectOptionList = new List<SelectOption> {new SelectOption('', NONE)};
        String targetAppliedApi;
        for (String eachAppliedLabel : appliedLabelList) {
            if (allLabelList.contains(eachAppliedLabel)) {
                targetAppliedApi = allApiList.get(allLabelList.indexOf(eachAppliedLabel));
            }
            appliedSelectOptionList.add(new SelectOption(targetAppliedApi, eachAppliedLabel));
        }
        return appliedSelectOptionList;
    }
 
    // 检索按钮
    public void searchBtn() {
        System.debug('Enter searchBtn.');
        System.debug('fromQuickBarFlag2 === ' + fromQuickBarFlag);
        System.debug('checkFromQuickBarFlag===' + checkFromQuickBarFlag);
        returnFirstPageFlag = true;
        getAllAssetData();
    }
    // 取消按钮 先清空所有打钩项
    public void clearAllCheckedBtn() {
        searchFromBtn = true;
        returnFirstPageFlag = false;  // 取消时不回到首页
        getAllAssetData();
    }
 
    // 明细排序
    public void sortTable() {
        searchFromBtn = false;  // 点击排序时,不需要清空打勾
        returnFirstPageFlag = true;  // 排序时回到首页
        // 排序
        this.sortKey = ApexPages.currentPage().getParameters().get('sortKey');
 
        System.debug('###########sortKey='+this.sortKey);
        System.debug('###########preSortKey='+this.preSortKey);
 
        if (this.sortKey == this.preSortKey) {
            // 方向が変わるのみ
            this.sortOrderAsc = !this.sortOrderAsc;
            this.sortOrderList[Integer.valueOf(this.sortKey)] = (this.sortOrderAsc == true ? '↑' : '↓');
        } else {
            if (preSortKey == '') {
                preSortKey = '0';
            }
            this.sortOrderAsc = true;
            this.sortOrderList[Integer.valueOf(this.preSortKey)] = ' ';
            this.sortOrderList[Integer.valueOf(this.sortKey)] = (this.sortOrderAsc == true ? '↑' : '↓');
        }
        System.debug('###########sortOrderAsc='+this.sortOrderAsc);
        this.preSortKey = this.sortKey;
        // 获取排序后借出备品一览
        getAllAssetData();
    }
 
    // 获取保有设备
    private void getAllAssetData() {
        internalAssetLocation = searchB.internal_asset_location;
        List<AssetInfo> oldAssetInfoList = new List<AssetInfo>();
        List<AssetInfo> newAssetInfoList = new List<AssetInfo>();
        List<Id> oldAssetDataIdList = new List<Id>();
        List<Id> checkedSavingDataIdList = new List<Id>();
 
        if (allAssetInfoList.size() > 0) {
            for (AssetInfo eachOldAssetInfo : allAssetInfoList) {
                if (eachOldAssetInfo.isCheck == true) {
                    oldAssetInfoList.add(eachOldAssetInfo);
                    oldAssetDataIdList.add(eachOldAssetInfo.assetQuertResult.Id);
                    if (searchFromSave == true) {
                        checkedSavingDataIdList.add(eachOldAssetInfo.assetQuertResult.Id);
                    }
                }
            }
        }
        System.debug('oldAssetInfoList===' + oldAssetInfoList);
        checkedAssetInfoNum = oldAssetInfoList.size();
        allAssetInfoList.clear();
 
        totalFixDataNum = oldAssetInfoList.size(); // 打勾固定数据数量
 
        if (searchFromBtn == true || searchFromSave == true) {  // 来自导航快捷键,去掉打钩项
            oldAssetDataIdList.clear();
            oldAssetInfoList.clear();
            searchFromBtn = false;
            //searchFromSave = false;
            totalFixDataNum = 0;
        }
 
        allAssetInfoList.addAll(oldAssetInfoList);
        String dateToday = String.valueOf(Date.today());
        String soqlAsset = '';
        soqlAsset += 'SELECT Id, ' + targetColumusStr + ' FROM Asset ';
 
        //soqlAsset += 'WHERE RecordTypeId = \'' + System.Label.Asset_RecordType + '\' ';  // RecordType备品
        soqlAsset += 'WHERE Asset_Owner__c = \'' + 'Olympus' + '\' ';
        soqlAsset += 'AND Delete_Flag__c = false ';  // 逻辑删除
        soqlAsset += 'AND AssetManageConfirm__c = true ';  // 备品中心确认
 
        if (oldAssetDataIdList.size() > 0) {
            soqlAsset += 'AND Id NOT IN :oldAssetDataIdList ';
        }
 
        if (String.isNotBlank(assertQueryCondition)) {  // 导航区快捷键备品状态
            if (assertQueryCondition == 'all') {  // 备品检索条件assertQueryCondition为空视为 查看全部保佑设备
                assetStatus = NONE;
            } else if (assertQueryCondition == 'consumable') {
                assetStatus = NONE;
                soqlAsset += 'AND You_Xiao_Ku_Cun__c > 0 ';  // 有效库存
            } else if (assertQueryCondition == 'lending') {  //  查看出借中保有设备
                assetStatus = NONE;
                soqlAsset += 'AND Out_of_wh__c > 0 ';  // 借出分配数
            } else if (assertQueryCondition == 'repairing') {  //  修理中
                assetStatus = NONE;
                soqlAsset += 'AND (Repairing_Count__c > 0 OR Draft_Repair_Count__c > 0) ';  // 修理中件数 + 草案中修理件数 > 0
            } else if (assertQueryCondition == 'scrapping') {  //  待报废
                assetStatus = NONE;
                soqlAsset += 'AND (Abandoned_RealThing__c > 0 OR Abandoned_Inventory__c  > 0) ';  // 待废弃数(实物) 或者 待废弃数(丢失/盘亏)
            } else if (assertQueryCondition == 'scrapped') {  //  已报废
                assetStatus = FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Fei_Qi.ordinal());
            } else if (assertQueryCondition == 'consumed') {  //  已消耗
                assetStatus = NONE;
                soqlAsset += 'AND Consumed_Count__c > 0 ';// 已消耗数大于0
            } else if (assertQueryCondition == 'soonExpired') {  //  即将到期
                assetStatus = NONE;
                Datetime time1 = Datetime.now();
                Datetime future = time1.addMonths(1);
                // 这次能用format的原因是左边是Date类型,右边是DateTime类型
                // 如果左边和右边都是DateTime类型的话就不能这么用了,因为Salfesforce里面保存的是格林志时间
                soqlAsset += 'AND (Consumable_Guaranteen_end__c > ' + time1.format('YYYY-MM-dd') + ' AND Consumable_Guaranteen_end__c <= ' + future.format('YYYY-MM-dd') + ') ';
                //  1个月内即将到期的
            } else if (assertQueryCondition == 'expired') {  //  已过期
                assetStatus = NONE;
                soqlAsset += 'AND Expired_Count_F__c > 0 ';//  已过期数>0
            }
        }
        String notScriptedAssetStatus1 = '';
        System.debug('assetStatus111==' + assetStatus);
        System.debug('fromQuickBarFlag3==' + fromQuickBarFlag);
        System.debug('checkFromQuickBarFlag===' + checkFromQuickBarFlag);
        if(assetStatus != FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Fei_Qi.ordinal()) && checkFromQuickBarFlag == 'false') {
            assetStatus = searchB.fixture_Status;
        } else if (searchB.fixture_Status != NONE && checkFromQuickBarFlag == 'false') {  // 如果查看废弃保有设备同时选择了其他备品状态
            notScriptedAssetStatus1 = searchB.fixture_Status;
        }
        System.debug('assetStatus222==' + assetStatus);
        System.debug('notScriptedAssetStatus1==' + notScriptedAssetStatus1);
        fromQuickBarFlag = 'false';
        if (checkFromQuickBarFlag == null || checkFromQuickBarFlag == 'true') {
            internalAssetLocation = '';
        }
        if (UserInfo.getProfileId() != System.Label.ProfileId_SystemAdmin && !(System.Label.ProfileId_EquCenAdmin.contains(UserInfo.getProfileId()))) {  // ProfileId 2B3_备品中心管理者
            if (String.isBlank(internalAssetLocation)) {
                internalAssetLocation = loginUserList[0].Default_Referable_Apply_Equipment_Center__c;  // User.默认可参照备品中心
                searchB.internal_asset_location = loginUserList[0].Default_Referable_Apply_Equipment_Center__c;  // User.默认可参照备品中心
            }
        }
        if (String.isNotBlank(internalAssetLocation)) {
            //系统管理员 ,2B3_备品中心管理者, 2B3_备品中心管理者(照片) 可以进行更新
            if (UserInfo.getProfileId() == System.Label.ProfileId_SystemAdmin || System.Label.ProfileId_EquCenAdmin.contains(UserInfo.getProfileId())) {
                onlyReadFlag = false;
                if (internalAssetLocation != '全部' && internalAssetLocation != 'All') {
                    soqlAsset += 'AND Internal_asset_location__c = \'' + String.escapeSingleQuotes(internalAssetLocation) + '\' ';
                }// 20210628 you 1650 AgencyProfileId 办事处没有更改得权限 
            } else if (internalAssetLocation != loginUserList[0].Default_Referable_Apply_Equipment_Center__c || System.Label.AgencyProfileId.contains(UserInfo.getProfileId())){
                onlyReadFlag = true;
                if (internalAssetLocation != '全部' && internalAssetLocation != 'All') {
                    soqlAsset += 'AND Internal_asset_location__c = \'' + String.escapeSingleQuotes(internalAssetLocation) + '\' ';
                }
            } else {
                onlyReadFlag = false;
                if (internalAssetLocation != '全部' && internalAssetLocation != 'All') {
                    soqlAsset += 'AND Internal_asset_location__c = \'' + String.escapeSingleQuotes(internalAssetLocation) + '\' ';
                }
            }  // 备品存放地
        }
        if (String.isNotBlank(searchB.fixture_Model_No) && checkFromQuickBarFlag == 'false') {
            soqlAsset += 'AND Fixture_Model_No_F__c LIKE \'%' + String.escapeSingleQuotes(searchB.fixture_Model_No.trim().replaceAll('%', '\\%')) + '%\' ';
        }  // 备品配套明细型号
        if (String.isNotBlank(searchB.wh_location) && checkFromQuickBarFlag == 'false') {
            soqlAsset += 'AND WH_Location__c = \'' + String.escapeSingleQuotes(searchB.wh_location.trim()) + '\' ';
        }  // 货架号
        if (assetStatus != NONE && assetStatus != null && assetStatus != '') {
            System.debug('assetStatus=======' + assetStatus);
            if (assetStatus ==  FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Xiu_Li_Zhong.ordinal())) {  // 修理中
                // 个体管理: 备品状态; 数量管理: 修理中件数 + 草案中修理件数 > 0
                soqlAsset += 'AND (Fixture_Status__c = \'' + String.escapeSingleQuotes(assetStatus) + '\' ';
                soqlAsset += 'OR (Repairing_Count__c > 0 ';
                soqlAsset += 'OR Draft_Repair_Count__c > 0)) ';
            } else if (assetStatus ==  FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Dai_Fei_Qi.ordinal())) {  // 待报废
                // 个体管理: 备品状态; 数量管理: 待废弃数(实物) > 0
                soqlAsset += 'AND (Fixture_Status__c = \'' + String.escapeSingleQuotes(assetStatus) + '\' ';
                soqlAsset += 'OR Abandoned_RealThing__c > 0) ';
            } else if (assetStatus ==  FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Fei_Qi.ordinal())) {  // 已报废
                // 备品状态
                soqlAsset += 'AND Fixture_Status__c = \'' + String.escapeSingleQuotes(assetStatus) + '\' ';
            } else {
                assetStatus = assetStatus == '废弃' ? FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Fei_Qi.ordinal()) : assetStatus;
                soqlAsset += 'AND Fixture_Status__c = \'' + String.escapeSingleQuotes(assetStatus) + '\' ';
            }
            if (notScriptedAssetStatus1 != '') {
                soqlAsset += 'AND Fixture_Status__c = \'' + String.escapeSingleQuotes(notScriptedAssetStatus1) + '\' ';
            }
        }  // 备品状态
        if (String.isNotBlank(searchB.equipmentSet_Managment_Code) && checkFromQuickBarFlag == 'false') {
            soqlAsset += 'AND EquipmentSet_Managment_Code__c = \'' + String.escapeSingleQuotes(searchB.equipmentSet_Managment_Code.trim()) + '\' ';
        }  // 备品管理编码
        if (String.isNotBlank(searchB.internal_Asset_number) && checkFromQuickBarFlag == 'false') {
            soqlAsset += 'AND Internal_Asset_number__c = \'' + String.escapeSingleQuotes(searchB.internal_Asset_number.trim()) + '\' ';
        }  // 固定资产编号
        if (String.isNotBlank(searchB.serialNumber) && checkFromQuickBarFlag == 'false') {
            soqlAsset += 'AND SerialNumber = \'' + String.escapeSingleQuotes(searchB.serialNumber.trim()) + '\' ';
        }  // 机身号 シリアル番号
        if (String.isNotBlank(searchB.companyOfEquipment) && checkFromQuickBarFlag == 'false') {
            soqlAsset += 'AND CompanyOfEquipment__c = \'' + String.escapeSingleQuotes(searchB.companyOfEquipment) + '\' ';
        }  // 财务所属分公司
        if (searchB.bodyOrAccessory != NONE && searchB.bodyOrAccessory != null && searchB.bodyOrAccessory != '' && checkFromQuickBarFlag == 'false') {
            if (searchB.bodyOrAccessory == '主体') {
                soqlAsset += 'AND Loaner_accsessary__c = false ';
            } else {
                soqlAsset += 'AND Loaner_accsessary__c = true ';
            }
        }  // 主体/附属品
        if (String.isNotBlank(searchB.product_category) && checkFromQuickBarFlag == 'false') {
            soqlAsset += 'AND Product_category__c = \'' + String.escapeSingleQuotes(searchB.product_category.trim()) + '\' ';
        }  // 产品分类
        if (String.isNotBlank(searchB.equipment_Type) && checkFromQuickBarFlag == 'false') {
            soqlAsset += 'AND Equipment_Type__c = \'' + String.escapeSingleQuotes(searchB.equipment_Type.trim()) + '\' ';
        }  // 备品分类
        if (String.isNotBlank(searchB.manage_type) && checkFromQuickBarFlag == 'false') {
            soqlAsset += 'AND Manage_type__c = \'' + String.escapeSingleQuotes(searchB.manage_type.trim()) + '\' ';
        }  // 管理种类
        if (String.isNotBlank(searchB.salesdepartment) && checkFromQuickBarFlag == 'false') {
            soqlAsset += 'AND Salesdepartment__c = \'' + String.escapeSingleQuotes(searchB.salesdepartment.trim()) + '\' ';
        }  // 所在地区 本部 Saless_Department__c
        if (String.isNotBlank(searchB.salesProvince) && checkFromQuickBarFlag == 'false') {
            soqlAsset += 'AND SalesProvince__c = \'' + String.escapeSingleQuotes(searchB.salesProvince.trim()) + '\' ';
        }  // 所在地区 省 Sales_Province__c
        if (String.isNotBlank(searchB.asset_loaner_category) && checkFromQuickBarFlag == 'false') {
            if(searchB.asset_loaner_category == '耗材') {
                soqlAsset += 'AND Asset_loaner_category__c = \'耗材\'';
            }
            else {
                soqlAsset += 'AND Asset_loaner_category__c != \'耗材\'';
            }
        }  // 备品类别
        if (String.isNotBlank(searchB.daysToExpired) && checkFromQuickBarFlag == 'false') {
            Datetime time1 = Datetime.now();
            Datetime future = time1.addDays(Integer.valueOf(searchB.daysToExpired));
            // 这次能用format的原因是左边是Date类型,右边是DateTime类型
            // 如果左边和右边都是DateTime类型的话就不能这么用了,因为Salfesforce里面保存的是格林志时间
            soqlAsset += 'AND (Consumable_Guaranteen_end__c > ' + time1.format('YYYY-MM-dd') + ' AND Consumable_Guaranteen_end__c <= ' + future.format('YYYY-MM-dd') + ') ';
        }  // 到期时间
        if (searchB.consumable_Guaranteen_end != NULL && checkFromQuickBarFlag == 'false') {
            Date tempDate;
            tempDate = searchB.consumable_Guaranteen_end;
            // if (consumableGuaranteenEndEditableFlag) {
            //     tempDate = searchB.consumable_Guaranteen_end;
            // } else {
            //     tempDate = consumableGuaranteenEndDate;
            // }
            soqlAsset += 'AND Consumable_Guaranteen_end__c = :tempDate ';
        }  // 消耗品有效期至 Consumable_Guaranteen_End__c
        // ---------------检索区---------------
 
        if (!allApiList.contains('Id')) {
            allApiList.add(0, 'Id');
        }
        // 判断2000条限制
        System.debug('soql2000===' + soqlAsset.right(299) + ' LIMIT 2001 ');
        Integer allAssetDataCheckSize = Database.query(soqlAsset + ' LIMIT 2001 ').size();
        excess2000Flag = false;
        if(allAssetDataCheckSize > 2000) {
            excess2000Flag = true;
            ApexPages.Message excess2000Msg = new ApexPages.Message(ApexPages.severity.WARNING, '检索数据已超过2000条,无法显示超过2000条的部分,请追加检索条件。');
            ApexPages.addMessage(excess2000Msg);
        }
 
        soqlAsset += ' ORDER BY ' + this.allApiList[Integer.valueOf(this.sortKey)] + ' ' + (this.sortOrderAsc == true ? 'asc nulls first ' : 'desc nulls last ');
        totalSoqlRecordNum = allAssetDataCheckSize > 2000 ? 2000 : allAssetDataCheckSize;
        totalNum = oldAssetDataIdList.size() + totalSoqlRecordNum;  // 总的显示数量
        totalPage = (totalNum/selctRecordNum) + (Math.mod(totalNum, selctRecordNum) > 0 ? 1 : 0);  // 总页数
        if (returnFirstPageFlag) {
            currPage = 1;
        }
        System.debug('currPage===' + currPage);
        System.debug('totalPage===' + totalPage);
        if (selRecordOption != NONE) {
            // selRecordOption = String.valueOf(Integer.valueOf(selRecordOption) + checkedAssetInfoNum);
            if (currPage == 1) {
                soqlAsset += ' limit ' + selRecordOption;
            } else if (currPage >= totalPage) {
                currPage = totalPage;
                soqlAsset += ' limit ' + selRecordOption + ' offset ' + String.valueOf((currPage - 1) * selctRecordNum - checkedAssetInfoNum);
                System.debug('Last page;');
            } else {
                soqlAsset += ' limit ' + selRecordOption + ' offset ' + String.valueOf((currPage - 1) * selctRecordNum - checkedAssetInfoNum);
            }
        }
        // 最终检索结果
        allAssetDataList = Database.query(soqlAsset);
 
        if (allAssetDataList.size() > 0) {
            for (Asset eachAssetDataList : allAssetDataList) {
                AssetInfo resultAssertInfo = new AssetInfo();
                resultAssertInfo.assetQuertResult = eachAssetDataList;
                resultAssertInfo.isCheck = false;
                newAssetInfoList.add(resultAssertInfo);
            }
            allAssetInfoList.addAll(newAssetInfoList);
        }
 
        System.debug('Asset soql====' + soqlAsset);
        totalUnfixDataNum = allAssetInfoList.size() - totalFixDataNum;
 
        if (searchFromSave == true) {
            List<Asset> headAssetList = new List<Asset>();  // 暂存打勾项, 优先显示
            List<AssetInfo> headAssetInfoList = new List<AssetInfo>();  // 暂存打勾项, 优先显示
            List<AssetInfo> trailAssetInfo = new List<AssetInfo>();
            List<AssetInfo> tempAssetInfoList = new List<AssetInfo>(allAssetInfoList);
            allAssetInfoList.clear();
            // 获取打勾固定项
            headAssetList = Database.query('SELECT Id, ' + targetColumusStr + ' FROM Asset WHERE Id IN :checkedSavingDataIdList LIMIT 2000');
            for (Asset eachheadAsset : headAssetList) {
                AssetInfo tempHeadAssetInfo = new AssetInfo();
                tempHeadAssetInfo.isCheck = true;
                tempHeadAssetInfo.assetQuertResult = eachheadAsset;
                headAssetInfoList.add(tempHeadAssetInfo);
            }
            for (AssetInfo eachAssetInfo : tempAssetInfoList) {
                if (!checkedSavingDataIdList.contains(eachAssetInfo.assetQuertResult.Id)) {
                    trailAssetInfo.add(eachAssetInfo);
                }
            }
            allAssetInfoList.addAll(headAssetInfoList);
            allAssetInfoList.addAll(trailAssetInfo);
            searchFromSave = false;
        }
        checkFromQuickBarFlag = 'false';
        System.debug('allAssetInfoList===' + allAssetInfoList);
        System.debug('Test allAssetInfoListallAssetInfoList = ' + allAssetInfoList);
    }
 
    // csv export
    public PageReference csvExprot() {
        exportCsvResultList = new List<List<String>>();
        if (allApiList.contains('Id')) {
            allApiList.remove(0);
        }
        assetExportCsvList = new List<Asset>();
        for (AssetInfo eachAssetInfo : allAssetInfoList) {
            List<String> exportCsvRowList = new List<String>();
            if (eachAssetInfo.isCheck) {
                exportCsvRowList.add(eachAssetInfo.assetQuertResult.Id);
                for (String eachApi : allApiList) {
                    System.debug('----====----');
                    System.debug(eachApi);
                    System.debug(eachAssetInfo.assetQuertResult.get(eachApi));
                    System.debug('++++:::::++++');
                    if (eachAssetInfo.assetQuertResult.get(eachApi) != null) {
                        //exportCsvRowList.add(String.valueOf(eachAssetInfo.assetQuertResult.get(eachApi)).escapeCsv());
                        exportCsvRowList.add(String.valueOf(eachAssetInfo.assetQuertResult.get(eachApi)));
                    } else {
                        exportCsvRowList.add(''.escapeCsv());
                    }
                }
                exportCsvResultList.add(exportCsvRowList);
                System.debug('exportCsvRowList===' + exportCsvRowList);
            }
        }
        return Page.ExportAllOlympusAsset.setRedirect(false);
    }
 
    // 适用按钮
    public void applyBtn() {
        String strMessage = null;
    }
 
    // 适用区域信息提示
    public void showApplyMsg() {
        String applyMsg = ApexPages.currentPage().getParameters().get('applyMsg');
        String applyMsgType = ApexPages.currentPage().getParameters().get('applyMsgType');
        String applyErrorLabel = ApexPages.currentPage().getParameters().get('applyErrorLabel');
        if(applyMsgType == 'Fail') {
            ApexPages.Message vfApplyMsg = new ApexPages.Message(ApexPages.severity.ERROR, applyMsg);
            ApexPages.addMessage(vfApplyMsg);
            System.debug('applyMsg===' + applyMsg);
            System.debug('applyMsgType===' + applyMsgType);
            System.debug('applyErrorLabel===' + applyErrorLabel);
            if(applyErrorLabel != null) {
                System.debug('applyErrorLabel===' + applyErrorLabel);
            }
        } else {
            ApexPages.Message vfApplyMsg = new ApexPages.Message(ApexPages.severity.INFO, applyMsg);
            ApexPages.addMessage(vfApplyMsg);
        }
    }
 
    // 保存按钮 当保存时先将修改flag置0,只更新打勾的,未打勾的将在下次保存时刷掉。
    public PageReference saveBtn() {
        isSavingSuccess = 'true';
        List<Asset> saveAssetList = new List<Asset>();
        if (changeFlg == '1') {
            changeFlg = '0';
        }
        Set<Id> assetId = new Set<Id>();
        for (AssetInfo eachAssetInfoList : allAssetInfoList) {
            // 只更新打勾的
            if (eachAssetInfoList.isCheck == true) {
                saveAssetList.add(eachAssetInfoList.assetQuertResult);
                assetId.add(eachAssetInfoList.assetQuertResult.Id);
            }
        }
        totalFixDataNum = saveAssetList.size(); // 打勾固定数据数量
        totalUnfixDataNum = allAssetInfoList.size() - totalFixDataNum; // 未打勾固定数据数量
        Boolean errorFlag = false;
        Boolean errorFlaglook = false;
        String errorMsg = '保存失败,导入CSV数据存在问题。';
        //Map <String, String> errorSavingMap = new Map <String, String>();
        if (saveAssetList.size() > 0) {
            Map<Id, Asset> assMap = new Map<Id, Asset>();
            for (Asset ass : [Select Id, LastModifiedDate FROM Asset Where Id = :assetId for Update]) {
                assMap.put(ass.Id, ass);
            }
            System.debug('saveAssetList');
            //Savepoint spAsset = Database.setSavepoint();
            // Database.update(saveAssetList);  // withsharing
            Map<String, SObjectField> saveAssetFieldMap = Asset.getSObjectType().getDescribe().fields.getMap();
            for (Asset eachSavingAsset : saveAssetList) {
                for (String eachApi : allApiList) {
                    DescribeFieldResult saveAssetFieldResult = saveAssetFieldMap.get(eachApi).getDescribe();
                    if (!saveAssetFieldResult.isCalculated()) {
                        if (saveAssetFieldResult.getType() == Schema.DisplayType.Picklist) {
                            List<Schema.PicklistEntry> ple = saveAssetFieldResult.getPicklistValues();
                            List<String> pleList = new List<String>();
                            for (Schema.PicklistEntry s : ple) {
                                pleList.add(s.getValue());
                            }
                            if (!pleList.contains(String.valueOf(eachSavingAsset.get(eachApi))) && String.valueOf(eachSavingAsset.get(eachApi)) != null) {
                                errorFlag = true;
                                isSavingSuccess = 'false';
                                String targetLabel = allLabelList.get(allApiList.indexOf(eachApi) - 1);  // allApiList[0]为Id,allLabelList中不存在。
                                String errorMsgField = targetLabel + ' 中不存在 ' + String.valueOf(eachSavingAsset.get(eachApi)) + '。 ';
                                System.debug('targetLabel===' + targetLabel);
                                System.debug('eachApi===' + eachApi);
                                if (eachApi == 'Internal_asset_location__c') {  // 备品存放地
                                    eachSavingAsset.Internal_asset_location__c.addError(errorMsgField);
                                } else if (eachApi == 'Salesdepartment__c') {  // 所在地区(本部)
                                    eachSavingAsset.Salesdepartment__c.addError(errorMsgField);
                                } else if (eachApi == 'SalesProvince__c') {  // 所在地区(省)
                                    eachSavingAsset.SalesProvince__c.addError(errorMsgField);
                                } else if (eachApi == 'CompanyOfEquipment__c') {  // 备品所属公司
                                    eachSavingAsset.CompanyOfEquipment__c.addError(errorMsgField);
                                } else if (eachApi == 'Product_category__c') {  // 产品分类(GI/SP)
                                    eachSavingAsset.Product_category__c.addError(errorMsgField);
                                } else if (eachApi == 'Equipment_Type__c') {  // 备品分类
                                    eachSavingAsset.Equipment_Type__c.addError(errorMsgField);
                                } else if (eachApi == 'Manage_type__c') {  // 管理种类
                                    eachSavingAsset.Manage_type__c.addError(errorMsgField);
                                } else if (eachApi == 'Asset_loaner_category__c') { // 备品类别
                                    eachSavingAsset.Asset_loaner_category__c.addError(errorMsgField);
                                }
                            }
                        }
                    }
                }
                if (assMap.containsKey(eachSavingAsset.Id) && assMap.get(eachSavingAsset.Id).LastModifiedDate != eachSavingAsset.LastModifiedDate) {
                    ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR, '保有设备:' + eachSavingAsset.Fixture_Model_No_F__c + ' ' + eachSavingAsset.SerialNumber + '有被更新过,请刷新画面重试');
                    ApexPages.addMessage(errorMessage);
                    errorFlaglook = true;
                }
                System.debug('errorFlag===' + errorFlag);
            }
            if (errorFlaglook) {
                isSavingSuccess = 'false';
                return null;
            }
            if (errorFlag) {
                System.debug('errorFlagerrorFlag' + errorFlag);
                isSavingSuccess = 'false';
                System.debug('errorMsg' + errorMsg);
 
                ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR, errorMsg);
                ApexPages.addMessage(errorMessage);
 
                errorFlag = false;
 
                return null;
            }
            //if(!errorSavingMap.isEmpty()) {
            //    String errorMsg;
            //    errorMsg += '导入CSV数据存在问题,';
            //    for (String eachErrorApiKey : errorSavingMap.keySet()) {
            //        System.debug('eachErrorApiKey' + eachErrorApiKey);
            //        String eachErrorValue = String.valueOf(errorSavingMap.get(eachErrorApiKey));
            //        System.debug('eachErrorValue' + eachErrorValue);
            //        errorMsg += eachErrorApiKey + '中不存在' + eachErrorValue;
            //    }
            //    System.debug(errorMsg);
            //}
 
            //ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR, '导入过程出现错误,请检查CSV文件格式。');
            //ApexPages.addMessage(errorMessage);
 
            try {
                System.debug('saveAssetList====----===' + saveAssetList);
                Database.SaveResult[] saveResultList = FixtureUtil.withoutUpdate(saveAssetList, true);  // withoutsharing
                //Database.SaveResult[] saveResultList = Database.update(saveAssetList, true);
                getAllAssetData();
            } catch (Exception e) {
                //Database.rollback(spAsset);
                System.debug('eeee' + e);
            }
        }
        searchFromSave = true;
 
        return null;
    }
 
    // 保存完了信息提示
    public void setSaveSuccessMsg() {
        ApexPages.Message savingSuccessfullyMessage = new ApexPages.Message(ApexPages.severity.INFO, '保存成功。');
        ApexPages.addMessage(savingSuccessfullyMessage);
    }
 
    public Date stringToDate(String dateStr) {  // Fri Jan 18 00:00:00 GMT 2019
        //System.debug('dateStr=====' + dateStr);
        return Date.valueOf(dateStr);
        //String monthStr = dateStr.substring(4,7);
        //Integer dayStr = Integer.ValueOf(dateStr.substring(8,10));
        //Integer yearStr = Integer.ValueOf(dateStr.substring(24,28));
        //Integer strMonth;
        //switch on monthStr {
        //    when 'Jan' {
        //        strMonth = 01;
        //    } when 'Feb' {
        //        strMonth = 02;
        //    } when 'Mar' {
        //        strMonth = 03;
        //    } when 'Apr' {
        //        strMonth = 04;
        //    } when 'May' {
        //        strMonth = 05;
        //    } when 'Jun' {
        //        strMonth = 06;
        //    } when 'Jul' {
        //        strMonth = 07;
        //    } when 'Aug' {
        //        strMonth = 08;
        //    } when 'Sep' {
        //        strMonth = 09;
        //    } when 'OCt' {
        //        strMonth = 10;
        //    } when 'Nov' {
        //        strMonth = 11;
        //    } when 'Dec' {
        //        strMonth = 12;
        //    }
        //}
        //return date.newinstance(yearStr, strMonth, dayStr);
    }
 
    public void importCSVFile() {
        System.debug('*************importCSVFile*************');
        allAssetInfoList.clear();  // 清空检索结果
        allAssetDataList.clear();  // 清空检索结果 用于统计数量
        String csvData = ApexPages.currentPage().getParameters().get('csvData');
        System.debug('------' + csvData + '------');
        System.debug('111111');
        List<List<String>> tempCsvBody = CSVReader.readIETFRFC4180CSVFile(Blob.valueof(csvData));  // 全部CSV数据
        System.debug('222222');
        List<String> importApiList = tempCsvBody[0];  // CSV读入的标题行 ID + Label
        List<String> importLabelList = tempCsvBody[1];  // CSV读入的标题行 ID + Label
        Map<Id, Asset> importAssetMap = new Map<Id, Asset>();  // 导入CSV生成的AssetList
        // 检查CSV列是否一一对应
        List<String> allLabelList = new List<String>();  // 默认的 ID + Label
        if (!allLabelList.contains('Id')) {
            allLabelList.add('Id');
        }
        allLabelList.addAll(leftLabelList);
        allLabelList.addAll(rightLabelList);
        for (Integer i = 0; i < importLabelList.size(); i++) {
            if (importLabelList[i].contains('不可修改')) {
                importLabelList[i] = importLabelList[i].remove('(不可修改)');
            }
        }
        System.debug('333333');
        // 检索CSV中的ID检索Asset获得List<Asset>
        try {
            if (allApiList.contains('Id')) {
                allApiList.remove(0);
            }
            if (importApiList.contains('Id(不可修改)')) {
                importApiList.remove(0);
            }
            List<String> notIncludeApiList = new List<String>();
            for (String eachApi : allApiList) {
                if ((!importApiList.contains(eachApi)) && (!importApiList.contains(eachApi+'(不可修改)'))) {
                    notIncludeApiList.add(eachApi);
                }
            }
 
            Map<String, SObjectField> queryAssetFieldMap = Asset.getSObjectType().getDescribe().fields.getMap();
            for (Integer i = 2; i < tempCsvBody.size(); i++) {
                Asset tempAsset = getAsset();
                System.debug('--------==========----------');
                System.debug('internalAssetLocationLogin===' + internalAssetLocationLogin);
                System.debug('1234' + tempCsvBody[i][1]);
                if (UserInfo.getProfileId() == System.Label.ProfileId_SystemAdmin || System.Label.ProfileId_EquCenAdmin.contains(UserInfo.getProfileId())) {
                    internalAssetLocationLogin = FixtureUtil.bieCunFangDiOpsMap.get('备品管理中心')[0].getValue();  // SelectOption('All', '--全部--')
                } else {
                    List<SelectOption> tempBieCunFangDiOpsList = FixtureUtil.bieCunFangDiOpsMap.get('备品管理中心');
                    internalAssetLocationLogin = beipinCunFangDi;
                }
                if(internalAssetLocationLogin != 'All' && tempCsvBody[i][1] != internalAssetLocationLogin) {
                    continue;
                }
                for (Integer j = 0; j < importApiList.size(); j++) {
 
                    if (importApiList[j].contains('(不可修改)')) {
                        importApiList[j] = importApiList[j].remove('(不可修改)');
                    }
                    DescribeFieldResult queryAssetFieldResult = queryAssetFieldMap.get(importApiList[j]).getDescribe();
                    if (!queryAssetFieldResult.isCalculated()) {
                        if (queryAssetFieldResult.getType() == Schema.DisplayType.Date) {
                            if (tempCsvBody[i][j+1] != '') {
                                tempAsset.put(importApiList[j], stringToDate(tempCsvBody[i][j+1]));
                            }
                        } else if (queryAssetFieldResult.getType() == Schema.DisplayType.Boolean) {
                            if (tempCsvBody[i][j+1] != '') {
                                tempAsset.put(importApiList[j], Boolean.valueOf(tempCsvBody[i][j+1]));
                            }
                        } else if (queryAssetFieldResult.getType() == Schema.DisplayType.Double) {
                            if (tempCsvBody[i][j+1] != '') {
                                tempAsset.put(importApiList[j], Decimal.valueOf(tempCsvBody[i][j+1]));
                            }
                        } else {
                            tempAsset.put(importApiList[j], tempCsvBody[i][j+1]);
                        }
                    }
                }
                importAssetMap.put(tempCsvBody[i][0], tempAsset);
            }
            System.debug('importAssetMap===---===' + importAssetMap);
            if (!importAssetMap.isEmpty()) {
                Set<Id> importAssetId = importAssetMap.keySet();
                String soqlAsset = '';
                soqlAsset += 'SELECT Id, ' + targetColumusStr + ' FROM Asset ';
                //soqlAsset += 'WHERE RecordTypeId = \'' + System.Label.Asset_RecordType + '\' ';
                soqlAsset += 'WHERE Asset_Owner__c = \'' + 'Olympus' + '\' ';
                soqlAsset += 'AND Id IN :importAssetId LIMIT 2000 ';
                //System.debug('soqlAsset====' + soqlAsset);
 
                // 导入csv时,获取相应的数据库中的数据与导入的CSV数据比较,只更新存在差异的文件。
                allAssetDataList = Database.query(soqlAsset);
                // importAssetMap => allAssetDataList Id
                for (Asset eachOldAsset : allAssetDataList) {
                    Asset updatingAsset = importAssetMap.get((Id)(eachOldAsset.get('Id')));
                    for (String eachAllApi : importApiList) {
                        DescribeFieldResult queryAssetFieldResult = queryAssetFieldMap.get(eachAllApi).getDescribe();
                        if (queryAssetFieldResult.isCalculated()) {
                            continue;
                        }
                        System.debug('test1');
                        if ((eachOldAsset.get(eachAllApi) != updatingAsset.get(eachAllApi)) && (!notIncludeApiList.contains(eachAllApi))) {
                            eachOldAsset.put(eachAllApi, updatingAsset.get(eachAllApi));
                        }
                        System.debug('test2');
                    }
                    System.debug('eachOldAsset-======' + eachOldAsset);
                    AssetInfo updatingAssetInfo = new AssetInfo();
                    updatingAssetInfo.isCheck = true;
                    updatingAssetInfo.assetQuertResult = eachOldAsset;
                    allAssetInfoList.add(updatingAssetInfo);
                    System.debug('allAssetInfoList===---' + allAssetInfoList);
                }
            }
            System.debug('test3');
            totalFixDataNum = allAssetInfoList.size();
            totalUnfixDataNum = allAssetInfoList.size() - totalFixDataNum;
            totalSoqlRecordNum = 0;
            Integer importAssetMapSize = importAssetMap.size();
            if (importAssetMapSize == 0) {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.WARNING, '未导入任何数据,请检查CSV文件'));
            } else {
                String importSuccessfulMsg = '导入CSV文件完成,成功导入' + importAssetMapSize + '条数据。';
                ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.INFO, importSuccessfulMsg);
                ApexPages.addMessage(errorMessage);
            }
        } catch (Exception e) {
            System.debug('1234 ' + e);
            ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR, '导入过程出现错误,导入文件中可能存在Fieldset中不存在的列名,请检查CSV文件。');
            ApexPages.addMessage(errorMessage);
        }
 
    }
 
    // 翻页到首页
    public Integer soqlNos(){
        getAllAssetData();
        return totalNum;
    }
    public void firstPage() {
        currPage = 1;
        totalNum = soqlNos();
        totalPage = (totalNum/selctRecordNum) + (Math.mod(totalNum, selctRecordNum) > 0 ? 1 : 0);
    }
 
    // 向前翻页
    public void previousPage() {
        returnFirstPageFlag = false;
        currPage --;
        totalNum = soqlNos();
        totalPage = (totalNum/selctRecordNum) + (Math.mod(totalNum, selctRecordNum) > 0 ? 1 : 0);
    }
 
    // 向后翻页
    public void nextPage() {
        returnFirstPageFlag = false;
        if (totalNum == 0) {
            currPage = 1;
        } else {
            currPage ++;
        }
        totalNum = soqlNos();
        System.debug('totalNum ==' + totalNum);
        totalPage = (totalNum/selctRecordNum) + (Math.mod(totalNum, selctRecordNum) > 0 ? 1 : 0);
        System.debug('totalPage ==' + totalPage);
        System.debug('currPage ==' + currPage);
    }
 
    // 翻页到尾页
    public void endPage() {
        System.debug('currPage11===' + currPage);
        System.debug('totalPage11===' + totalPage);
        returnFirstPageFlag = false;
        totalNum = soqlNos();  // 获取总页数
        totalPage = (totalNum/selctRecordNum) + (Math.mod(totalNum, selctRecordNum) > 0 ? 1 : 0);
        if (totalNum == 0){
            currPage  = 1;
        } else {
            currPage = totalPage;  // 将当前页数置为总页数
        }
        totalNum = soqlNos();
        System.debug('currPage1===' + currPage);
        System.debug('totalPage1===' + totalPage);
    }
 
    // 每页显示记录数变更
    public void recordNumChange() {
        currPage = 1;
        totalPage = (totalNum/selctRecordNum) + (Math.mod(totalNum, selctRecordNum) > 0 ? 1 : 0);
    }
    // 清空检索条件
    public void clearAllSearchConditionWhenCancel() {
        // 备品存放地
        //if (UserInfo.getProfileId() != System.Label.ProfileId_SystemAdmin) {
        //    if (String.isBlank(internalAssetLocation)) {
        //        internalAssetLocation = beipinCunFangDi;
        //    }
        //}
        // 对于备品管理者,2B3_备品中心管理者、2B3_备品中心管理者(照片) 默认显示北京、上海、广州备品中心的库存,可以检索
        //if (UserInfo.getProfileId() == System.Label.ProfileId_SystemAdmin || System.Label.ProfileId_EquCenAdmin.contains(UserInfo.getProfileId())) {
        //    internalAssetLocation1 = FixtureUtil.bieCunFangDiOpsMap.get('备品管理中心')[0].getValue();  // SelectOption('All', '--全部--')
        //} else {
        //    List<SelectOption> tempBieCunFangDiOpsList = FixtureUtil.bieCunFangDiOpsMap.get('备品管理中心');
        //    internalAssetLocation1 = beipinCunFangDi;
        //}
        searchB.internal_asset_location = internalAssetLocationLogin;
        searchB.fixture_Model_No = '';  // 备品配套明细型号
        searchB.wh_location = '';  // 货架号
        searchB.fixture_Status = '';  // 备品状态
        searchB.equipmentSet_Managment_Code = '';  // 备品管理编码
        searchB.internal_Asset_number = '';  // 固定资产号
        searchB.serialNumber = '';  // 机身号
        searchB.companyOfEquipment = '';  // 分公司号
        searchB.bodyOrAccessory = '';  // 主体/附属品
        searchB.product_category = '';  // 产品分类
        searchB.equipment_Type = '';  // 备品分类
        searchB.manage_type = '';  // 管理种类
        searchB.salesdepartment = '';  // 所在地区(本部)
        searchB.salesProvince = '';  // 所在地区(省)
        searchB.consumable_Guaranteen_endStr = '';  // 消耗品有效期至
        searchB.asset_loaner_category = ''; // 备品类别
        searchB.daysToExpired = ''; // 到期时间
        System.debug('Before searching.');
        searchBtn();
    }
 
    public List<SelectOption> getPlickList(String objApi, String fieldApi) {
        Schema.DescribeFieldResult fieldResult = Schema.getGlobalDescribe().get(objApi).getDescribe().fields.getMap().get(fieldApi).getDescribe();
        List<SelectOption> pickListValuesList= new List<SelectOption>();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        pickListValuesList.add(new SelectOption('', NONE));
        for( Schema.PicklistEntry pickListVal : ple){
            pickListValuesList.add(new SelectOption(pickListVal.getValue(), pickListVal.getLabel()));
        }
        return pickListValuesList;
    }
 
    // 画面检索Bean
    public Class SearchBean {
        // 为了节省viewstate所以不使用Sobject
        // public Asset assetQuery {get; set;} // 查询用
        public String internal_asset_location {get; set;} // 备品存放地
        public String fixture_Model_No {get; set;}  // 备品配套明细型号 Fixture_Model_No__c
        public String wh_location {get; set;} // 货架号 WH_location__c
        public String fixture_Status {get; set;} // 备品状态
        public String equipmentSet_Managment_Code {get; set;} // 备品管理编码
        public String internal_Asset_number {get; set;} // 固定资产号
        public String serialNumber {get; set;} // 机身号
        public String companyOfEquipment {get; set;} // 分公司号
        public String bodyOrAccessory {get; set;} // 主体/附属品
        public String product_category {get; set;} // 产品分类
        public String equipment_Type {get; set;} // 备品分类
        public String manage_type {get; set;} // 管理种类
        public String salesdepartment {get; set;} // 所在地区(本部)
        public String salesProvince {get; set;} // 所在地区(省)
        public String asset_loaner_category {get; set;} // 备品类别
        public String daysToExpired {get;set;} // 到期时间
        public Date consumable_Guaranteen_end {get; set;} // 消耗品有效期至
        public String consumable_Guaranteen_endStr {
            get;
            set{
                consumable_Guaranteen_endStr = value;
                if (String.isNotBlank(consumable_Guaranteen_endStr)) {
                    consumable_Guaranteen_end = Date.valueOf(consumable_Guaranteen_endStr.replace('/', '-'));
                }
                else {
                    consumable_Guaranteen_end = null;
                }
            }
        } // 消耗品有效期至
    }
}