zxl
2025-04-27 ccba712602ff6eafe0928d79b6d595c140e924af
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
package com.ycl.task;
 
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mongodb.client.result.DeleteResult;
import com.ycl.feign.*;
import com.ycl.platform.domain.entity.CheckIndexCar;
import com.ycl.platform.domain.entity.CheckIndexFace;
import com.ycl.platform.domain.entity.TMonitor;
import com.ycl.platform.domain.param.HK.*;
import com.ycl.platform.domain.result.HK.*;
import com.ycl.platform.domain.result.UY.MonitorQualifyResult;
import com.ycl.platform.domain.result.UY.VideoOnlineResult;
import com.ycl.platform.domain.vo.UpdateOnlineVO;
import com.ycl.platform.mapper.CheckIndexCarMapper;
import com.ycl.platform.mapper.CheckIndexFaceMapper;
import com.ycl.platform.mapper.TMonitorMapper;
import com.ycl.platform.mapper.WorkOrderMapper;
import com.ycl.platform.service.*;
import com.ycl.utils.DateUtils;
import constant.ApiConstants;
import constant.CheckConstants;
import enumeration.general.AreaDeptEnum;
import enumeration.general.PublishType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.client.loadbalancer.LoadBalancerRequestFactory;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
 
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
 
//海康对接数据任务
@Slf4j
@Component("HKTask")
public class HKTask {
 
    @Value("${HK.host}")
    public String host;
    @Value("${HK.appKey}")
    public String appKey;
    @Value("${HK.appSecret}")
    public String appSecret;
    @Value("${HK.carCode}")
    public String carCode;
    @Value("${HK.faceCode}")
    public String faceCode;
    @Value("${HK.carProvinceCode}")
    public String carProvinceCode;
    @Value("${HK.faceProvinceCode}")
    public String faceProvinceCode;
    @Autowired
    private MongoTemplate mongoTemplate;
    @Autowired
    private IYwThresholdService ywThresholdService;
    @Autowired
    private YwPointService pointService;
    @Autowired
    private TMonitorMapper monitorMapper;
    @Autowired
    private UYErrorTypeCheckService uyErrorTypeCheckService;
    @Autowired
    private HKClient hkClient;
    @Autowired
    private ICheckIndexCarService carService;
    @Autowired
    private CheckIndexCarMapper carMapper;
    @Autowired
    private ICheckIndexFaceService faceService;
    @Autowired
    private CheckIndexFaceMapper faceMapper;
 
    //车辆设备全检指标监测结果
    public void vehicleDeviceInspectionTask() {
        log.info("开始执行车辆设备全检指标监测结果数据同步");
        VehicleDeviceInspectionParam param = new VehicleDeviceInspectionParam();
        param.setPageNo(ApiConstants.PageNo);
        param.setPageSize(ApiConstants.HKPageSize);
        param.setDate(DateUtils.getDate());
        param.setDataType(ApiConstants.HK_DataType_CAR);
        List<VehicleDeviceInspectionResult> list = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v2/data/vehFullAmount/query", param, VehicleDeviceInspectionResult.class);
        if (!CollectionUtils.isEmpty(list)) {
            //如果存在之前的数据先删除
            Query query = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())));
            DeleteResult result = mongoTemplate.remove(query, VehicleDeviceInspectionResult.class);
            list.stream().forEach(item -> {
                if (Objects.nonNull(item.getExternalIndexCode())) {
                    item.setNo(item.getExternalIndexCode());
                }
            });
            pointService.setDeviceTagByGB(list, CheckConstants.Rule_Category_Car);
            //存放在mongo中
            mongoTemplate.insertAll(list);
            //同步的数据进行工单阈值处理
            ywThresholdService.carCheck(list);
        }
        // 本地测试
//        Query query = new Query(Criteria.where("mongoCreateTime").lt(DateUtils.getDayEnd(new Date())));
//        ywThresholdService.carCheck(mongoTemplate.find(query, VehicleDeviceInspectionResult.class));
        log.info("结束车辆设备全检指标监测结果数据同步");
    }
 
    //人脸设备全检指标监测结果
    public void faceDeviceInspectionTask() {
        log.info("开始执行人脸设备全检指标监测结果数据同步");
        FaceDeviceInspectionParam param = new FaceDeviceInspectionParam();
        param.setPageNo(ApiConstants.PageNo);
        param.setPageSize(ApiConstants.HKPageSize);
        param.setDate(DateUtils.getDate());
        List<FaceDeviceInspectionResult> list = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v2/data/faceFullAmount/query", param, FaceDeviceInspectionResult.class);
        if (!CollectionUtils.isEmpty(list)) {
            //如果存在之前的数据先删除
            Query query = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())));
            DeleteResult result = mongoTemplate.remove(query, FaceDeviceInspectionResult.class);
            list.stream().forEach(item -> {
                if (Objects.nonNull(item.getExternalIndexCode())) {
                    item.setNo(item.getExternalIndexCode());
                }
            });
            pointService.setDeviceTagByGB(list, CheckConstants.Rule_Category_Face);
            //存放在mongo中
            mongoTemplate.insertAll(list);
            //同步的数据进行工单阈值处理
            ywThresholdService.faceCheck(list);
        }
//        Query query = new Query(Criteria.where("mongoCreateTime").lt(DateUtils.getDayEnd(new Date())));
//        ywThresholdService.faceCheck(mongoTemplate.find(query, FaceDeviceInspectionResult.class));
        log.info("结束人脸设备全检指标监测结果数据同步");
    }
 
 
    // 抓拍数据量监测结果
    public void snapshotDataMonitorTask() {
        log.info("开始执行抓拍数据量检测结果数据同步");
        /** 车辆数据 */
        SnapshotDataMonitorParam carParam = new SnapshotDataMonitorParam();
        carParam.setPageNo(ApiConstants.PageNo);
        carParam.setPageSize(ApiConstants.HKPageSize);
        carParam.setDate(DateUtils.getDate());
        carParam.setDataType(ApiConstants.HK_DataType_CAR);
        List<SnapshotDataMonitorResult> carList = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v1/data/snapCountDetail/query", carParam, SnapshotDataMonitorResult.class);
        if (!CollectionUtils.isEmpty(carList)) {
            //如果今天存在之前的数据先删除
            Query query = new Query(Criteria
                    .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))
                    .and("dataType").is(ApiConstants.HK_DataType_CAR));
            DeleteResult result = mongoTemplate.remove(query, SnapshotDataMonitorResult.class);
            carList.stream().forEach(item -> {
                if (Objects.nonNull(item.getExternalIndexCode())) {
                    item.setNo(item.getExternalIndexCode());
                }
            });
            pointService.setDeviceTagByGB(carList, CheckConstants.Rule_Category_Car);
            //存放在mongo中
            carList.forEach(item -> item.setDataType(ApiConstants.HK_DataType_CAR));
            mongoTemplate.insertAll(carList);
        }
 
        /** 人脸数据 */
        SnapshotDataMonitorParam faceParam = new SnapshotDataMonitorParam();
        faceParam.setPageNo(ApiConstants.PageNo);
        faceParam.setPageSize(ApiConstants.HKPageSize);
        faceParam.setDate(DateUtils.getDate());
        faceParam.setDataType(ApiConstants.HK_DataType_FACE);
        List<SnapshotDataMonitorResult> faceList = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v1/data/snapCountDetail/query", faceParam, SnapshotDataMonitorResult.class);
        if (!CollectionUtils.isEmpty(faceList)) {
            //如果今天存在之前的数据先删除
            Query query = new Query(Criteria
                    .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))
                    .and("dataType").is(ApiConstants.HK_DataType_FACE));
            DeleteResult result = mongoTemplate.remove(query, SnapshotDataMonitorResult.class);
            faceList.stream().forEach(item -> {
                if (Objects.nonNull(item.getExternalIndexCode())) {
                    item.setNo(item.getExternalIndexCode());
                }
            });
            pointService.setDeviceTagByGB(faceList, CheckConstants.Rule_Category_Face);
            //存放在mongo中
            faceList.forEach(item -> item.setDataType(ApiConstants.HK_DataType_FACE));
            mongoTemplate.insertAll(faceList);
        }
        //修改online状态
        List<SnapshotDataMonitorResult> totalResult = new ArrayList<>();
        totalResult.addAll(carList);
        totalResult.addAll(faceList);
        if (!CollectionUtils.isEmpty(totalResult)) {
            //先拿优云的在线,过滤掉优云已有的国标码
            Query query = new Query();
            query.addCriteria(Criteria
                    .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())));
            List<VideoOnlineResult> results = mongoTemplate.find(query, VideoOnlineResult.class);
            if (!CollectionUtils.isEmpty(results)) {
                Date now = new Date();
                List<String> uyNoList = results.stream().map(VideoOnlineResult::getNo).collect(Collectors.toList());
                List<String> numbers = totalResult.stream().filter(result->!uyNoList.contains(result.getExternalIndexCode()))
                        .map(SnapshotDataMonitorResult::getExternalIndexCode).collect(Collectors.toList());
                //排除掉优云且不包含视频设备的国标
                Map<String, TMonitor> map = monitorMapper.selectList(new QueryWrapper<TMonitor>()
                                .in("serial_number", numbers))
                        .stream().filter(monitor -> monitor.getCameraFunType()!=null && !monitor.getCameraFunType().contains("1"))
                        .collect(Collectors.toMap(TMonitor::getSerialNumber, Function.identity()));
                List<UpdateOnlineVO> willUpdateList = new ArrayList<>();
                totalResult.forEach(item -> {
                    TMonitor monitor = map.get(item.getExternalIndexCode());
                    if(monitor!=null) {
                        UpdateOnlineVO vo = new UpdateOnlineVO();
                        vo.setOnline(item.getDataCount() > 0 ? 1 : -1);
                        vo.setSerialNumber(monitor.getSerialNumber());
                        vo.setUpdateTime(now);
                        willUpdateList.add(vo);
                    }
                });
                if(!CollectionUtils.isEmpty(willUpdateList)) monitorMapper.updateOnlineFromHk(willUpdateList);
//            List<UpdateOnlineVO> willUpdateList = totalResult.stream().map(item -> {
//                UpdateOnlineVO vo = new UpdateOnlineVO();
//                vo.setOnline(item.getDataCount() > 0 ? 1 : -1);
//                vo.setIp(map.get(item.getExternalIndexCode()).getIp());
//                vo.setUpdateTime(now);
//                return vo;
//            }).collect(Collectors.toList());
//            monitorMapper.updateOnlineFromUyOrHk(willUpdateList);
//            //离线生成工单,一个ip只生成一个工单
//            List<SnapshotDataMonitorResult> workOrders = new ArrayList<>(totalResult.stream()
//                    .filter(item -> ApiConstants.UY_OnlineSite_Offline.equals(item.getDataCount() > 0 ? 1 : -1))
//                    .collect(Collectors.toMap(
//                            SnapshotDataMonitorResult::getIp,
//                            Function.identity(),
//                            (existing, replacement) -> existing // 如果遇到相同的 IP,保留第一个(existing)
//                    )).values());
//            uyErrorTypeCheckService.hkOnlineCheck(workOrders);
            }
        }
        log.info("结束抓拍数据量检测结果数据同步");
    }
 
    //采集设备属性监测结果(人脸)
    public void monitorDetailTask() {
        log.info("开始执行采集设备属性监测结果数据同步");
        //人脸卡口信息采集准确率
        MonitoringDetailParam param = new MonitoringDetailParam();
        param.setPageNo(ApiConstants.PageNo);
        param.setPageSize(ApiConstants.HKPageSize);
        param.setDate(DateUtils.getDate());
        List<MonitoringDetailResult> faceList = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v1/device/cameraExpDetailInfo/query", param, MonitoringDetailResult.class);
        if (!CollectionUtils.isEmpty(faceList)) {
            //如果今天存在之前的数据先删除
            Query query = new Query(Criteria
                    .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())));
            DeleteResult result = mongoTemplate.remove(query, MonitoringDetailResult.class);
            faceList.stream().forEach(item -> {
                if (Objects.nonNull(item.getExternalIndexCode())) {
                    item.setNo(item.getExternalIndexCode());
                }
            });
            pointService.setDeviceTagByGB(faceList, CheckConstants.Rule_Category_Face);
            //存放在mongo中
            mongoTemplate.insertAll(faceList);
        }
        log.info("结束采集设备属性监测结果数据同步");
    }
 
    //卡口属性监测结果
    public void crossDetailTask() {
        log.info("开始执行卡口属性监测结果数据同步");
        //车辆卡口信息采集准确率
        CrossDetailParam param = new CrossDetailParam();
        param.setPageNo(ApiConstants.PageNo);
        param.setPageSize(ApiConstants.HKPageSize);
        param.setDate(DateUtils.getDate());
        List<CrossDetailResult> carList = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v1/device/crossExpDetailInfo/query", param, CrossDetailResult.class);
        if (!CollectionUtils.isEmpty(carList)) {
            //如果今天存在之前的数据先删除
            Query query = new Query(Criteria
                    .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())));
            DeleteResult result = mongoTemplate.remove(query, CrossDetailResult.class);
            carList.stream().forEach(item -> {
                if (Objects.nonNull(item.getExternalIndexCode())) {
                    item.setNo(item.getExternalIndexCode());
                }
            });
            pointService.setDeviceTagByGB(carList, CheckConstants.Rule_Category_Car);
            //存放在mongo中
            mongoTemplate.insertAll(carList);
        }
        log.info("结束卡口属性监测结果数据同步");
    }
 
    //数据完整性监测结果
    public void dataIntegrityMonitoringTask() {
        log.info("开始执行数据完整性监测结果数据同步");
        //车辆卡口设备抓拍数据完整性
        DataIntegrityMonitoringParam param = new DataIntegrityMonitoringParam();
        param.setPageNo(ApiConstants.PageNo);
        param.setPageSize(ApiConstants.HKPageSize);
        param.setDate(DateUtils.getDate());
        param.setDataType(ApiConstants.HK_DataType_CAR);
        List<DataIntegrityMonitoringResult> carList = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v1/data/attributeIntegrity/query", param, DataIntegrityMonitoringResult.class);
 
        if (!CollectionUtils.isEmpty(carList)) {
            //如果今天存在之前的数据先删除
            Query query = new Query(Criteria
                    .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())));
            DeleteResult result = mongoTemplate.remove(query, DataIntegrityMonitoringResult.class);
            carList.stream().forEach(item -> {
                if (Objects.nonNull(item.getExternalIndexCode())) {
                    item.setNo(item.getExternalIndexCode());
                }
            });
            pointService.setDeviceTagByGB(carList, CheckConstants.Rule_Category_Car);
            //存放在mongo中
            mongoTemplate.insertAll(carList);
        }
        log.info("结束数据完整性监测结果数据同步");
    }
 
    //属性识别准确监测结果
    public void attrRecognitionMonitorTask() {
        log.info("开始执行属性识别准确监测结果数据同步");
        //车辆卡口设备抓拍数据准确性
        AttrRecognitionParam param = new AttrRecognitionParam();
        param.setPageNo(ApiConstants.PageNo);
        param.setPageSize(ApiConstants.HKPageSize);
        param.setDate(DateUtils.getDate());
        param.setDataType(ApiConstants.HK_DataType_CAR);
        List<AttrRecognitionMonitorResult> carList = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v1/data/attributeRecognition/query", param, AttrRecognitionMonitorResult.class);
 
        if (!CollectionUtils.isEmpty(carList)) {
            //如果今天存在之前的数据先删除
            Query query = new Query(Criteria
                    .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())));
            DeleteResult result = mongoTemplate.remove(query, AttrRecognitionMonitorResult.class);
            carList.stream().forEach(item -> {
                if (Objects.nonNull(item.getExternalIndexCode())) {
                    item.setNo(item.getExternalIndexCode());
                }
            });
            pointService.setDeviceTagByGB(carList, CheckConstants.Rule_Category_Car);
            //存放在mongo中
            mongoTemplate.insertAll(carList);
        }
        log.info("结束属性识别准确监测结果数据同步");
 
    }
 
    //抓拍数据时延监测结果
    public void snapshopDelayMonitorTask() {
        log.info("开始执行抓拍数据时延监测结果数据同步");
        //车辆卡口设备抓拍数据上传及时性
        /** 车辆数据 */
        SnapshotDelayMonitorParam carParam = new SnapshotDelayMonitorParam();
        carParam.setPageNo(ApiConstants.PageNo);
        carParam.setPageSize(ApiConstants.HKPageSize);
        carParam.setDate(DateUtils.getDate());
        carParam.setDataType(ApiConstants.HK_DataType_CAR);
        List<SnapshotDelayMonitorResult> carList = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v1/data/snapAgingDetail/query", carParam, SnapshotDelayMonitorResult.class);
 
        if (!CollectionUtils.isEmpty(carList)) {
            //如果今天存在之前的数据先删除
            Query query = new Query(Criteria
                    .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))
                    .and("dataType").is(ApiConstants.HK_DataType_CAR));
            DeleteResult result = mongoTemplate.remove(query, SnapshotDelayMonitorResult.class);
            //存放在mongo中
            carList.stream().forEach(item -> {
                item.setDataType(ApiConstants.HK_DataType_CAR);
                if (Objects.nonNull(item.getExternalIndexCode())) {
                    item.setNo(item.getExternalIndexCode());
                }
            });
            pointService.setDeviceTagByGB(carList, CheckConstants.Rule_Category_Car);
            mongoTemplate.insertAll(carList);
        }
 
        /** 人脸数据 */
        SnapshotDelayMonitorParam faceParam = new SnapshotDelayMonitorParam();
        faceParam.setPageNo(ApiConstants.PageNo);
        faceParam.setPageSize(ApiConstants.HKPageSize);
        faceParam.setDate(DateUtils.getDate());
        faceParam.setDataType(ApiConstants.HK_DataType_FACE);
        List<SnapshotDelayMonitorResult> faceList = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v1/data/snapAgingDetail/query", faceParam, SnapshotDelayMonitorResult.class);
 
        if (!CollectionUtils.isEmpty(faceList)) {
            //如果今天存在之前的数据先删除
            Query query = new Query(Criteria
                    .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))
                    .and("dataType").is(ApiConstants.HK_DataType_FACE));
            DeleteResult result = mongoTemplate.remove(query, SnapshotDelayMonitorResult.class);
            //存放在mongo中
            faceList.forEach(item -> {
                item.setDataType(ApiConstants.HK_DataType_FACE);
                if (Objects.nonNull(item.getExternalIndexCode())) {
                    item.setNo(item.getExternalIndexCode());
                }
            });
            pointService.setDeviceTagByGB(faceList, CheckConstants.Rule_Category_Face);
            mongoTemplate.insertAll(faceList);
        }
        log.info("结束抓拍数据时延监测结果数据同步");
    }
 
    //图片访问监测结果
    public void picAccessTask() {
        log.info("开始执行图片访问监测结果数据同步");
        //车辆卡口信息采集准确率、车辆卡口设备url可用性
        PicAccessParam param = new PicAccessParam();
        param.setPageNo(ApiConstants.PageNo);
        param.setPageSize(ApiConstants.HKPageSize);
        param.setDate(DateUtils.getDate());
        param.setDataType(ApiConstants.HK_DataType_CAR);
        List<PicAccessResult> carList = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v1/data/picAccessDetail/query", param, PicAccessResult.class);
 
        if (!CollectionUtils.isEmpty(carList)) {
            //如果今天存在之前的数据先删除
            Query query = new Query(Criteria
                    .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())));
            DeleteResult result = mongoTemplate.remove(query, PicAccessResult.class);
            carList.stream().forEach(item -> {
                if (Objects.nonNull(item.getExternalIndexCode())) {
                    item.setNo(item.getExternalIndexCode());
                }
            });
            pointService.setDeviceTagByGB(carList, CheckConstants.Rule_Category_Car);
            //存放在mongo中
            mongoTemplate.insertAll(carList);
        }
        log.info("结束图片访问监测结果数据同步");
    }
 
    //车辆设备抽检指标监测结果
    public void vehicleDeviceSamplingTask() {
        log.info("开始执行车辆设备抽检指标监测结果数据同步");
        //车辆卡口信息采集准确率、车辆卡口设备url可用性
        VehicleDeviceSamplingParam param = new VehicleDeviceSamplingParam();
        param.setPageNo(ApiConstants.PageNo);
        param.setPageSize(ApiConstants.HKPageSize);
        param.setDate(DateUtils.getDate());
        param.setDataType(ApiConstants.HK_DataType_CAR);
        List<VehicleDeviceSamplingResult> carList = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v2/data/vehSampleAmount/query", param, VehicleDeviceSamplingResult.class);
 
        if (!CollectionUtils.isEmpty(carList)) {
            //如果今天存在之前的数据先删除
            Query query = new Query(Criteria
                    .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())));
            DeleteResult result = mongoTemplate.remove(query, VehicleDeviceSamplingResult.class);
            carList.stream().forEach(item -> {
                if (Objects.nonNull(item.getExternalIndexCode())) {
                    item.setNo(item.getExternalIndexCode());
                }
            });
            pointService.setDeviceTagByGB(carList, CheckConstants.Rule_Category_Car);
            //存放在mongo中
            mongoTemplate.insertAll(carList);
        }
        log.info("结束车辆设备抽检指标监测结果数据同步");
    }
 
 
    //人脸设备抽检指标监测结果
    public void faceDeviceSamplingTask() {
        log.info("开始执行人脸设备抽检指标监测结果数据同步");
        FaceDeviceSamplingParam param = new FaceDeviceSamplingParam();
        param.setPageNo(ApiConstants.PageNo);
        param.setPageSize(ApiConstants.HKPageSize);
        param.setDate(DateUtils.getDate());
        List<FaceDeviceSamplingResult> faceList = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v2/data/faceSampleAmount/query", param, FaceDeviceSamplingResult.class);
 
        if (!CollectionUtils.isEmpty(faceList)) {
            //如果今天存在之前的数据先删除
            Query query = new Query(Criteria
                    .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())));
            DeleteResult result = mongoTemplate.remove(query, FaceDeviceSamplingResult.class);
            faceList.stream().forEach(item -> {
                if (Objects.nonNull(item.getExternalIndexCode())) {
                    item.setNo(item.getExternalIndexCode());
                }
            });
            pointService.setDeviceTagByGB(faceList, CheckConstants.Rule_Category_Face);
            //存放在mongo中
            mongoTemplate.insertAll(faceList);
        }
        log.info("结束人脸设备抽检指标监测结果数据同步");
    }
 
    //考核成绩
//    public void HkScoreTask() {
//        log.info("开始执行海康考核成绩数据");
//        //准备新增或修改的数据
//        List<CheckIndexCar> cars = new ArrayList<>();
//        List<CheckIndexFace> faces = new ArrayList<>();
//        // 查询是否index表已经存在今日数据
//        List<CheckIndexFace> checkIndexFaceList = faceMapper.selectToday(utils.DateUtils.getDate());
//        List<CheckIndexCar> checkIndexCarList = carMapper.selectToday(utils.DateUtils.getDate());
//
//        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
//        // 获取当前时间的Calendar实例
//        Calendar calendar = Calendar.getInstance();
//        // 设置时间为前一天
//        calendar.add(Calendar.DATE, -1);
//        // 获取前一天的Date对象
//        Date yesterday = calendar.getTime();
//        //先请求全量数据
//        ScoreParam param = new ScoreParam();
//        param.setStartDate(format.format(yesterday));
//        param.setEndDate(format.format(yesterday));
////        param.setFocusFlag(ApiConstants.HK_FOCUS_FLAG_ALL);
////        param.setCarTree(carCode);
////        param.setFaceTree(faceCode);
//        JSONObject scoreJson = hkClient.getScore(param);
//        if (scoreJson != null) {
//            String code = scoreJson.getString("code");
//            if (ApiConstants.HKSuccessCode.equals(code)) {
//                List<HKScoreResult> data = scoreJson.getList("data", HKScoreResult.class);
//
//                //根据数据转换为index对象
//                data.forEach(score -> {
//                    CheckIndexCar car = new CheckIndexCar();
//                    CheckIndexFace face = new CheckIndexFace();
//                    score2Index(score, car, face);
//                    car.setExamineTag(CheckConstants.Examine_Tag_County);
//                    face.setExamineTag(CheckConstants.Examine_Tag_County);
//                    Optional<CheckIndexCar> carFirst = checkIndexCarList.stream()
//                            .filter(index -> CheckConstants.Examine_Tag_County.equals(index.getExamineTag()) && car.getDeptId().equals(index.getDeptId()))
//                            .findFirst();
//                    Optional<CheckIndexFace> faceFirst = checkIndexFaceList.stream()
//                            .filter(index -> CheckConstants.Examine_Tag_County.equals(index.getExamineTag()) && face.getDeptId().equals(index.getDeptId()))
//                            .findFirst();
//                    if (carFirst.isPresent()) {
//                        car.setId(carFirst.get().getId());
//                    }
//                    if (faceFirst.isPresent()) {
//                        face.setId(faceFirst.get().getId());
//                    }
//                    cars.add(car);
//                    faces.add(face);
//                });
//            }
//        }
//
//        //先请求省厅数据
//        ScoreParam provinceParam = new ScoreParam();
//        provinceParam.setStartDate(format.format(yesterday));
//        provinceParam.setEndDate(format.format(yesterday));
////        provinceParam.setFocusFlag(ApiConstants.HK_FOCUS_FLAG_ALL);
////        provinceParam.setCarTree(carProvinceCode);
////        provinceParam.setFaceTree(faceProvinceCode);
//        JSONObject scoreProvinceJson = hkClient.getScore(provinceParam);
//        if (scoreProvinceJson != null) {
//            String code = scoreProvinceJson.getString("code");
//            if (ApiConstants.HKSuccessCode.equals(code)) {
//                List<HKScoreResult> data = scoreProvinceJson.getList("data", HKScoreResult.class);
//
//                //根据数据转换为index对象
//                data.forEach(score -> {
//                    CheckIndexCar car = new CheckIndexCar();
//                    CheckIndexFace face = new CheckIndexFace();
//                    score2Index(score, car, face);
//                    car.setExamineTag(CheckConstants.Examine_Tag_Province);
//                    face.setExamineTag(CheckConstants.Examine_Tag_Province);
//                    Optional<CheckIndexCar> carFirst = checkIndexCarList.stream()
//                            .filter(index -> CheckConstants.Examine_Tag_Province.equals(index.getExamineTag()) && car.getDeptId().equals(index.getDeptId()))
//                            .findFirst();
//                    Optional<CheckIndexFace> faceFirst = checkIndexFaceList.stream()
//                            .filter(index -> CheckConstants.Examine_Tag_Province.equals(index.getExamineTag()) && face.getDeptId().equals(index.getDeptId()))
//                            .findFirst();
//                    if (carFirst.isPresent()) {
//                        car.setId(carFirst.get().getId());
//                    }
//                    if (faceFirst.isPresent()) {
//                        face.setId(faceFirst.get().getId());
//                    }
//                    cars.add(car);
//                    faces.add(face);
//                });
//            }
//        }
//        //存放成绩到mysql,如果存在则替换不存在就新增。
//        if (!CollectionUtils.isEmpty(cars)) carService.saveOrUpdateBatch(cars);
//        if (!CollectionUtils.isEmpty(faces)) faceService.saveOrUpdateBatch(faces);
//        log.info("结束海康考核成绩数据");
//    }
 
    public void HkScoreTask(){
        log.info("开始执行海康考核成绩数据");
        //先执行获得标签 因为全量默认传参为null,但是省厅数据需要获得标签
        JSONObject labelJson = hkClient.getGetLabel();
        Integer faceLabelId = null;
        Integer carLabelId = null;
        if (labelJson != null) {
            String code = labelJson.getString("code");
            if (ApiConstants.HKSuccessCode.equals(code)){
                //获得label考核标签对象
                log.error("labelJson的data:{}",labelJson.get("data"));
                List<HKResultLabel> hkResultLabels = labelJson.getList("data",HKResultLabel.class);
                for (HKResultLabel label : hkResultLabels) {
                    if ("省厅人脸".equals(label.getLabelName())){
                        faceLabelId = label.getId();
                    }else if ("省厅车辆".equals(label.getLabelName())){
                        carLabelId = label.getId();
                    }
                }
                log.error("打印hkResultLabels:{}",hkResultLabels);
 
            }
        }
        if (faceLabelId == null || carLabelId == null){
            log.error("海康获取省厅考核标签为null");
        }
 
        //准备新增或修改的数据
        List<CheckIndexCar> cars = new ArrayList<>();
        List<CheckIndexFace> faces = new ArrayList<>();
        // 查询是否index表已经存在今日数据
        List<CheckIndexFace> checkIndexFaceList = faceMapper.selectToday(utils.DateUtils.getDate());
        List<CheckIndexCar> checkIndexCarList = carMapper.selectToday(utils.DateUtils.getDate());
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        // 获取当前时间的Calendar实例
        Calendar calendar = Calendar.getInstance();
        // 设置时间为前一天
        calendar.add(Calendar.DATE, -1);
        // 获取前一天的Date对象
        Date yesterday = calendar.getTime();
 
        ScoreParam param = new ScoreParam();
//        param.setStartDate(format.format(yesterday));
//        param.setEndDate(format.format(yesterday));
//        param.setLabelId();
 
        //------------默认参数为null请求全量数据
        JSONObject scoreJson = hkClient.getScoreNew(param);
        log.error("全量数据");
        if (scoreJson != null) {
            List<HkResultInfo> allInfo = new ArrayList<>();
            String code = scoreJson.getString("code");
            if (ApiConstants.HKSuccessCode.equals(code)){
                JSONObject data = scoreJson.getJSONObject("data");
 
                Map<Integer,JSONObject> map = new HashMap<>();
                //获得data 下 batchId 的批次id对象 放入map中
                for (String batchIdKey :data.keySet() ) {
                    JSONObject batch = data.getJSONObject(batchIdKey);
                    //以批次id为key 放入 JSONObject对象
                    map.put(Integer.valueOf(batchIdKey),batch);
                    //批次id 下 各区信息集合
                    log.error("打印出data内容中批次id:{},以及对应的结果info:{}",batchIdKey,batch);
                }
                //获得最大的键值
                Optional<Integer> maxKey = map.keySet().stream()
                        .max(Integer::compareTo);
                if (maxKey.isPresent()) {
                    //获取最大的key 接口返回内容中最新的批次
                    Integer id = maxKey.get();
                    //这一层为获得 data -> 中 批次数组中 -> 区域code数组的key
                    for (String areaCodeKey : map.get(id).keySet()) {
                        //存放最新批次的内容到allInfo集合中
                        log.error("打印区信息:{}",map.get(id).get(areaCodeKey));
                        allInfo.addAll(map.get(id).getList(areaCodeKey,HkResultInfo.class));
                    }
                }
                //对allInfo进行分组 分组按区域id
                Map<String, List<HkResultInfo>> groupedByAreaName = allInfo.stream()
                        .collect(Collectors.groupingBy(HkResultInfo::getAreaCode));
                for (Map.Entry<String, List<HkResultInfo>> entry : groupedByAreaName.entrySet()) {
                    log.error("最新批次内size:{}",groupedByAreaName.get(entry.getKey()).size());
                    log.error("最新批次内数据:{}",groupedByAreaName.get(entry.getKey()));
                    CheckIndexCar car = new CheckIndexCar();
                    CheckIndexFace face = new CheckIndexFace();
                    score3Index(groupedByAreaName.get(entry.getKey()), car, face,entry.getKey());
                    car.setExamineTag(CheckConstants.Examine_Tag_County);
                    face.setExamineTag(CheckConstants.Examine_Tag_County);
                    Optional<CheckIndexCar> carFirst = checkIndexCarList.stream()
                            .filter(index -> CheckConstants.Examine_Tag_County.equals(index.getExamineTag()) && car.getDeptId().equals(index.getDeptId()))
                            .findFirst();
                    Optional<CheckIndexFace> faceFirst = checkIndexFaceList.stream()
                            .filter(index -> CheckConstants.Examine_Tag_County.equals(index.getExamineTag()) && face.getDeptId().equals(index.getDeptId()))
                            .findFirst();
                    if (carFirst.isPresent()) {
                        car.setId(carFirst.get().getId());
                    }
                    if (faceFirst.isPresent()) {
                        face.setId(faceFirst.get().getId());
                    }
                    cars.add(car);
                    faces.add(face);
                }
                //请求省厅数据
            }else {
                log.error("调用海康全量数据api失败");
            }
 
        }
        //------------获取省厅数据
        List<HkResultInfo> provincialList = new ArrayList<>();
        //获取省厅人脸数据
        if (faceLabelId != null){
            ScoreParam faceParam = new ScoreParam();
            log.error("faceLabelId:{}",faceLabelId);
            faceParam.setLabelId(faceLabelId);
            JSONObject faceJson = hkClient.getScoreNew(faceParam);
            log.error("省厅人脸数据");
            if (faceJson != null) {
                String code = scoreJson.getString("code");
                if (ApiConstants.HKSuccessCode.equals(code)){
                    JSONObject data = scoreJson.getJSONObject("data");
 
                    Map<Integer,JSONObject> map = new HashMap<>();
                    //获得data 下 batchId 的批次id对象 放入map中
                    for (String batchIdKey :data.keySet() ) {
                        JSONObject batch = data.getJSONObject(batchIdKey);
                        //以批次id为key 放入 JSONObject对象
                        map.put(Integer.valueOf(batchIdKey),batch);
                        //批次id 下 各区信息集合
                        log.error("打印出省厅人脸data内容中批次id:{},以及对应的结果info:{}",batchIdKey,batch);
                    }
                    //获得最大的键值
                    Optional<Integer> maxKey = map.keySet().stream()
                            .max(Integer::compareTo);
                    if (maxKey.isPresent()) {
                        //获取最大的key 接口返回内容中最新的批次
                        Integer id = maxKey.get();
                        //这一层为获得 data -> 中 批次数组中 -> 区域code数组的key
                        for (String areaCodeKey : map.get(id).keySet()) {
                            //存放最新批次的内容到allInfo集合中
                            provincialList.addAll(map.get(id).getList(areaCodeKey,HkResultInfo.class));
                        }
                    }
 
                }else {
                    log.error("调用海康省厅人脸数据api失败");
                }
 
            }
        }else {
            log.error("faceLabelId:为空不执行获得省厅数据");
        }
        //获取省厅车辆数据v.
        if (carLabelId != null){
            ScoreParam carParam = new ScoreParam();
            log.error("carLabelId:{}",carLabelId);
            carParam.setLabelId(carLabelId);
            JSONObject carJson = hkClient.getScoreNew(carParam);
            log.error("省厅车辆数据");
            if (carJson != null) {
                String code = scoreJson.getString("code");
                if (ApiConstants.HKSuccessCode.equals(code)){
                    JSONObject data = scoreJson.getJSONObject("data");
 
                    Map<Integer,JSONObject> map = new HashMap<>();
                    //获得data 下 batchId 的批次id对象 放入map中
                    for (String batchIdKey :data.keySet() ) {
                        JSONObject batch = data.getJSONObject(batchIdKey);
                        //以批次id为key 放入 JSONObject对象
                        map.put(Integer.valueOf(batchIdKey),batch);
                        //批次id 下 各区信息集合
                        log.error("打印出省厅成辆data内容中批次id:{},以及对应的结果info:{}",batchIdKey,batch);
                    }
                    //获得最大的键值
                    Optional<Integer> maxKey = map.keySet().stream()
                            .max(Integer::compareTo);
                    if (maxKey.isPresent()) {
                        //获取最大的key 接口返回内容中最新的批次
                        Integer id = maxKey.get();
                        //这一层为获得 data -> 中 批次数组中 -> 区域code数组的key
                        for (String areaCodeKey : map.get(id).keySet()) {
                            //存放最新批次的内容到allInfo集合中
                            provincialList.addAll(map.get(id).getList(areaCodeKey,HkResultInfo.class));
                        }
                    }
                }else {
                    log.error("调用海康省厅车辆数据api失败");
                }
            }
        }else {
            log.error("carLabelId:为空不执行获得省厅数据");
        }
        //获取完数据开始分组
        Map<String,List<HkResultInfo>> provincialGroupedByAreaName = provincialList.stream()
                .collect(Collectors.groupingBy(HkResultInfo::getAreaCode));
        for (Map.Entry<String, List<HkResultInfo>> entry : provincialGroupedByAreaName.entrySet()) {
            log.error("最新批次内省厅数据:{}",provincialGroupedByAreaName.get(entry.getKey()).size());
            log.error("最新批次内省厅size:{}",provincialGroupedByAreaName.get(entry.getKey()));
            CheckIndexCar car = new CheckIndexCar();
            CheckIndexFace face = new CheckIndexFace();
            score3Index(provincialGroupedByAreaName.get(entry.getKey()), car, face,entry.getKey());
            car.setExamineTag(CheckConstants.Examine_Tag_Province);
            face.setExamineTag(CheckConstants.Examine_Tag_Province);
            Optional<CheckIndexCar> carFirst = checkIndexCarList.stream()
                    .filter(index -> CheckConstants.Examine_Tag_Province.equals(index.getExamineTag()) && car.getDeptId().equals(index.getDeptId()))
                    .findFirst();
            Optional<CheckIndexFace> faceFirst = checkIndexFaceList.stream()
                    .filter(index -> CheckConstants.Examine_Tag_Province.equals(index.getExamineTag()) && face.getDeptId().equals(index.getDeptId()))
                    .findFirst();
            if (carFirst.isPresent()) {
                car.setId(carFirst.get().getId());
            }
            if (faceFirst.isPresent()) {
                face.setId(faceFirst.get().getId());
            }
            cars.add(car);
            faces.add(face);
        }
        log.error("打印插入数据cars:{}",cars);
        log.error("打印插入数据faces:{}",faces);
        //存放成绩到mysql,如果存在则替换不存在就新增。
        if (!CollectionUtils.isEmpty(cars)) carService.saveOrUpdateBatch(cars);
        if (!CollectionUtils.isEmpty(faces)) faceService.saveOrUpdateBatch(faces);
        log.info("结束海康考核成绩数据");
    }
 
    private void score2Index(HKScoreResult score, CheckIndexCar car, CheckIndexFace face) {
        car.setDeptId(Long.parseLong(AreaDeptEnum.fromCode(score.getAreaCode()).getDeptId() + ""));
        car.setCreateTime(new Date());
        car.setPublish(PublishType.PUBLISHED.getCode());
        face.setDeptId(Long.parseLong(AreaDeptEnum.fromCode(score.getAreaCode()).getDeptId() + ""));
        face.setCreateTime(new Date());
        face.setPublish(PublishType.PUBLISHED.getCode());
 
        car.setViewConnectStability(new BigDecimal(score.getDownCarDataUploadScoreString() == null ? "1" : score.getDownCarDataUploadScoreString()));
        car.setSiteOnline(new BigDecimal(score.getDownCrossQualityCarScoreString() == null ? "1" : score.getDownCrossQualityCarScoreString()));
        car.setDeviceDirectoryConsistent(new BigDecimal(score.getDownCrossNumPushCarScoreString() == null ? "1" : score.getDownCrossNumPushCarScoreString()));
        //TODO:没找到考核项
        car.setVehicleInformationCollectionAccuracy(new BigDecimal("1"));
        car.setVehicleCaptureIntegrity(new BigDecimal(score.getDownCrossAllCarDataIntegrityScoreString() == null ? "1" : score.getDownCrossAllCarDataIntegrityScoreString()));
        //海康是设为1的,但是接口推的原始数据
        car.setVehicleCaptureAccuracy(new BigDecimal("1"));
        car.setVehicleTimingAccuracy(new BigDecimal(score.getDownCrossCarInvertScoreString() == null ? "1" : score.getDownCrossCarInvertScoreString()));
        car.setVehicleUploadTimeliness(new BigDecimal(score.getDownCrossAllCarDelayScoreString() == null ? "1" : score.getDownCrossAllCarDelayScoreString()));
        //TODO:没找到考核项
        car.setVehicleUrlAvailability(new BigDecimal("1"));
        car.setVehiclePictureAvailability(new BigDecimal(score.getDownCrossPictureQualityCarScoreString() == null ? "1" : score.getDownCrossPictureQualityCarScoreString()));
 
        face.setViewConnectStability(new BigDecimal(score.getDownFaceDataUploadScoreString() == null ? "1" : score.getDownFaceDataUploadScoreString()));
        face.setSiteOnline(new BigDecimal(score.getDownFaceDataUploadScoreString() == null ? "1" : score.getDownFaceDataUploadScoreString()));
        face.setDeviceDirectoryConsistent(new BigDecimal(score.getDownCrossNumPushFaceScoreString() == null ? "1" : score.getDownCrossNumPushFaceScoreString()));
        //TODO:没找到考核项
        face.setFaceInformationCollectionAccuracy(new BigDecimal("1"));
        //TODO:没找到考核项
        face.setFacePictureQualification(new BigDecimal("1"));
        face.setFaceTimingAccuracy(new BigDecimal(score.getDownCrossFaceInvertScoreString() == null ? "1" : score.getDownCrossFaceInvertScoreString()));
        face.setFaceUploadTimeliness(new BigDecimal(score.getDownCrossAllFaceDelayScoreString() == null ? "1" : score.getDownCrossAllFaceDelayScoreString()));
        face.setFacePictureAvailability(new BigDecimal(score.getDownCrossPictureQualityFaceScoreString() == null ? "1" : score.getDownCrossPictureQualityFaceScoreString()));
    }
 
    private void score3Index(List<HkResultInfo> score, CheckIndexCar car, CheckIndexFace face,String areaCode){
        car.setCreateTime(new Date());
        car.setPublish(PublishType.PUBLISHED.getCode());
        face.setCreateTime(new Date());
        face.setPublish(PublishType.PUBLISHED.getCode());
        car.setDeptId(Long.parseLong(AreaDeptEnum.fromCode(areaCode).getDeptId() + ""));
        face.setDeptId(Long.parseLong(AreaDeptEnum.fromCode(areaCode).getDeptId() + ""));
 
        for(HkResultInfo hkResultInfo : score){
            if (HKLabelName.carDelay.getCode().equals(hkResultInfo.getIndexCode())){
                //车辆卡口设备抓拍数据上传及时性
                car.setVehicleUploadTimeliness(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
            }else if (HKLabelName.carOnlineRate2023.getCode().equals(hkResultInfo.getIndexCode())){
                //车辆点位在线率
                car.setSiteOnline(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
            }else if (HKLabelName.carButtStability2023.getCode().equals(hkResultInfo.getIndexCode())){
                //车辆视图库对接稳定性
                car.setViewConnectStability(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
            }else if (HKLabelName.carQualifiedRate.getCode().equals(hkResultInfo.getIndexCode())){
                //车辆卡口设备抓拍数据完整性
                car.setVehicleCaptureIntegrity(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
            }else if (HKLabelName.carCorrectRate.getCode().equals(hkResultInfo.getIndexCode())){
                //车辆卡口设备抓拍数据准确性
                car.setVehicleCaptureAccuracy(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
            }else if (HKLabelName.carClockAccuracy.getCode().equals(hkResultInfo.getIndexCode())){
                //车辆卡口设备时钟准确性
                car.setVehicleTimingAccuracy(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
            }else if (HKLabelName.carBigPictureAccess.getCode().equals(hkResultInfo.getIndexCode())){
                //车辆卡口设备抓拍数据大图可用性
                car.setVehiclePictureAvailability(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
            }else if (HKLabelName.carUrlOkRate.getCode().equals(hkResultInfo.getIndexCode())){
                //车辆卡口设备url可用性
                car.setVehicleUrlAvailability(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
            }else if(HKLabelName.faceButtStability2023.getCode().equals(hkResultInfo.getIndexCode())){
                //人脸视图库对接稳定性
                face.setViewConnectStability(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
            }else if (HKLabelName.faceOnlineRate.getCode().equals(hkResultInfo.getIndexCode())){
                //人脸点位在线率
                face.setSiteOnline(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
            }else if (HKLabelName.faceCapturedPicturesEligibility.getCode().equals(hkResultInfo.getIndexCode())){
                //人脸设备抓拍图片合格性
                face.setFacePictureQualification(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
            }else if (HKLabelName.faceClockAccuracy.getCode().equals(hkResultInfo.getIndexCode())){
                //人脸设备抓拍图片时钟准确性
                face.setFaceTimingAccuracy(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
            }else if (HKLabelName.faceDelay.getCode().equals(hkResultInfo.getIndexCode())){
                //设备抓拍人脸数据上传及时性
                face.setFaceUploadTimeliness(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
            }else if (HKLabelName.faceBigPictureAccess.getCode().equals(hkResultInfo.getIndexCode())){
                //人脸卡口设备抓拍数据大图可用性
                face.setFacePictureAvailability(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
            }
        }
        //TODO:没找到考核项 人脸卡口信息采集准确率
        face.setFaceInformationCollectionAccuracy(new BigDecimal("1"));
        //TODO:没找到考核项 设备目录一致率
        face.setDeviceDirectoryConsistent(new BigDecimal("1"));
        //TODO:没找到考核项 车辆卡口信息采集准确率
        car.setVehicleInformationCollectionAccuracy(new BigDecimal("1"));
        //TODO:没找到考核项 联网卡口设备目录一致率
        car.setDeviceDirectoryConsistent(new BigDecimal("1"));
    }
 
    //解析数据
    private <T> List<T> getDataList(JSONObject jsonObject, Class<T> resultClass, String message) {
        if (jsonObject != null && ApiConstants.HKSuccessCode.equals(jsonObject.getString("code"))) {
            log.info("数据格式" + jsonObject);
            JSONObject data = jsonObject.getJSONObject("data");
            if (data == null) {
                log.error(message, jsonObject);
                return null;
            }
            List<T> list = data.getList("list", resultClass);
            if (CollectionUtils.isEmpty(list)) {
                log.error(message, data);
                return null;
            }
            return list;
        } else {
            log.error(message);
        }
        return null;
    }
}