jiangping
2024-08-14 17d3a171569b150cae8c240e69e4969e0ae34b03
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
package com.doumee.core.haikang;
 
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
 
 
public class HKUtil {
 
    private static final Logger logger = LoggerFactory.getLogger(HKUtil.class);
 
    /**
     * 请根据自己的appKey和appSecret更换static静态块中的三个参数. [1 host]
     * 如果你选择的是和现场环境对接,host要修改为现场环境的ip,https端口默认为443,http端口默认为80.例如10.33.25.22:443
     * 或者10.33.25.22:80 appKey和appSecret请按照或得到的appKey和appSecret更改. TODO
     * 调用前先要清楚接口传入的是什么,是传入json就用doPostStringArtemis方法,下载图片doPostStringImgArtemis方法
     */
    static {
 
    }
    public static void main(String[] args) throws ParseException {
 
    }
 
 
    /**
     * 能力开放平台的网站路径 TODO 路径不用修改,就是/artemis
     */
    private static final String ARTEMIS_PATH = "/artemis";
 
    public static JSONObject loginData(int page, int rows, String start, String end) {
        final String getCamsApi = ARTEMIS_PATH + "/api/acs/v2/door/events";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("startTime", start);
        jsonBody.put("endTime", end);
        jsonBody.put("receiveStartTime", start);
        jsonBody.put("receiveEndTime", end);
        jsonBody.put("pageNo", page);
        jsonBody.put("pageSize", rows);
        jsonBody.put("sort", "eventTime");
        jsonBody.put("order", "desc");
        String body = jsonBody.toJSONString();
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, "application/json", null);// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 访客查询
     * @param page
     * @param rows
     * @return
     */
    public static JSONObject fkData(int page, int rows, String visitorId) {
        final String getCamsApi = ARTEMIS_PATH + "/api/visitor/v1/event/turnover/search";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
        JSONObject jsonBody = new JSONObject();
 
        jsonBody.put("pageNo", page);
        jsonBody.put("pageSize", rows);
        jsonBody.put("visitorName", visitorId);
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, "application/json", null);// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 访客记录列表
     * @param page
     * @param rows
     * @return
     */
    public static JSONObject fkList(int page, int rows) {
        final String getCamsApi = ARTEMIS_PATH + "/api/visitor/v2/visiting/records";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
        JSONObject jsonBody = new JSONObject();
 
        jsonBody.put("pageNo", page);
        jsonBody.put("pageSize", rows);
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendPost(path, body);
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    private static String sendPost(Map<String, String> path, String body) {
        return ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, "application/json", null);
    }
 
    /**
     * 事件订阅
     * 正常开门--198913
     * @param code
     * @param url
     * @return
     */
    public static JSONObject event(int code, String url) {
        final String getCamsApi = ARTEMIS_PATH + "/api/eventService/v1/eventSubscriptionByEventTypes";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("eventTypes", Arrays.asList(code));
        jsonBody.put("eventDest", url);
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendPost(path, body);// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 取消事件订阅
     * @param code
     * @return
     */
    public static JSONObject eventCancle(int code) {
        final String getCamsApi = ARTEMIS_PATH + "/api/eventService/v1/eventUnSubscriptionByEventTypes";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("eventTypes", Arrays.asList(code));
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendPost(path, body);// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 查询订阅事件
     * @return
     */
    public static JSONObject eventQuery() {
        final String getCamsApi = ARTEMIS_PATH + "/api/eventService/v1/eventSubscriptionView";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
        JSONObject jsonBody = new JSONObject();
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendPost(path, body);// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 获取组织列表
     * @param page
     * @param rows
     * @return
     */
    public static JSONObject orgList(int page, int rows) {
        final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/org/orgList";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
        JSONObject jsonBody = new JSONObject();
 
        jsonBody.put("pageNo", page);
        jsonBody.put("pageSize", rows);
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendpost(path, body,"0","获取组织列表","0");// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        System.out.println(result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 添加组织
     * @param jsonArray
     * @return
     */
    public static JSONObject addOrg(JSONArray jsonArray) {
        final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/org/batch/add";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
 
        String body = jsonArray.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendpost(path, body,"0","添加组织","0");// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 修改组织
     * @param jsonBody
     * @return
     */
    public static JSONObject updateOrg(JSONObject jsonBody) {
        final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/org/single/update";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
 
        String body = jsonBody.toJSONString();
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendpost(path, body,"0","修改组织","0");// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 删除组织
     * @param jsonBody
     * @return
     */
    public static JSONObject delOrg(JSONObject jsonBody) {
        final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/org/batch/delete";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
 
        String body = jsonBody.toJSONString();
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendpost(path, body,"0","删除组织","0");// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 门禁设备列表
     * @param page
     * @param rows
     * @return
     */
    public static JSONObject deviceList(int page, int rows) {
        final String getCamsApi = ARTEMIS_PATH + "/api/resource/v2/acsDevice/search";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
        JSONObject jsonBody = new JSONObject();
 
        jsonBody.put("pageNo", page);
        jsonBody.put("pageSize", rows);
//        jsonBody.put("resourceType", "acsDevice");
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendpost(path, body,"0","获取门禁设备列表","0");
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 门禁点列表
     * @param page
     * @param rows
     * @return
     */
    public static JSONObject doorList(int page, int rows) {
        final String getCamsApi = ARTEMIS_PATH + "/api/resource/v2/door/search";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
        JSONObject jsonBody = new JSONObject();
 
        jsonBody.put("pageNo", page);
        jsonBody.put("pageSize", rows);
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendpost(path, body,"0","门禁点列表","0");
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 分页获取监控点资源列表
     * @param page
     * @param rows
     * @return
     */
    public static JSONObject camerasList(int page, int rows) {
        final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/cameras";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
        JSONObject jsonBody = new JSONObject();
 
        jsonBody.put("pageNo", page);
        jsonBody.put("pageSize", rows);
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendpost(path, body,"0","分页获取监控点资源","0");// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 获取监控点预览取流URL
     * @param code
     * @param streamType
     * @return
     */
    public static JSONObject previewURLs(String code, int streamType, String protocol, Integer transmode, String expand, String streamform) {
        final String getCamsApi = ARTEMIS_PATH + "/api/video/v2/cameras/previewURLs";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
        JSONObject jsonBody = new JSONObject();
 
        // 监控点唯一标识
        jsonBody.put("cameraIndexCode", code);
        // 码流类型,0:主码流,1:子码流,2:第三码流,参数不填,默认为主码流
/*        jsonBody.put("streamType", streamType);
        *//* 取流协议(应用层协议),“hik”:HIK私有协议,使用视频SDK进行播放时,传入此类型;“rtsp”,“rtmp”,“hls”,“ws”。参数不填,默认为HIK协议 *//*
        jsonBody.put("protocol", protocol);
        //传输协议(传输层协议),0:UDP,1:TCP。默认是TCP
        jsonBody.put("transmode", transmode);
        // 转码标志,不携带此字段或传0表示不转码,传1或2表示转码。
        jsonBody.put("expand", expand);
        // 输出码流转封装格式,“ps”:PS封装格式、“rtp”:RTP封装协议。当protocol=rtsp时生效,且不传值时默认为RTP封装协议。
        jsonBody.put("streamform", streamform);*/
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendpost(path, body,"0","获取监控点预览流","0");// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 添加人员
     * @param jsonBody
     * @return
     */
    public static JSONObject addPerson(JSONObject jsonBody) {
        final String getCamsApi = ARTEMIS_PATH + "/api/resource/v2/person/single/add";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
 
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendpost(path, body,"0","添加人员","0");// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 批量添加人员
     * @param jsonBody
     * @return
     */
    public static JSONObject batchSave(JSONArray jsonBody) {
        final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/person/batch/add";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
 
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendpost(path, body,"0","批量添加人员","0");// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 删除人员
     * @param jsonBody
     * @return
     */
    public static JSONObject delPerson(JSONObject jsonBody) {
        final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/person/batch/delete";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
 
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendpost(path, body,"0","删除人员","0");// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 获取人员卡号
     * @param jsonBody
     * @return
     */
    public static JSONObject getPersonCard(JSONObject jsonBody) {
        final String getCamsApi = ARTEMIS_PATH + "/api/irds/v1/card/advance/cardList";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
 
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendpost(path, body,"0","获取人员卡号","1");// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 同步人员
     * @param jsonBody
     * @return
     */
    public static JSONObject getPersonList(JSONObject jsonBody) {
        final String getCamsApi = ARTEMIS_PATH + "/api/resource/v2/person/advance/personList";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
 
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendpost(path, body,"0","获取人员列表","0");// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 修改人员信息,不含人脸
     * @param jsonBody
     * @return
     */
    public static JSONObject updatePerson(JSONObject jsonBody) {
        final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/person/single/update";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
 
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendpost(path, body,"0","修改人员信息","0");// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 添加人脸数据
     * @param jsonBody
     * @return
     */
    public static JSONObject addPersonFace(JSONObject jsonBody) {
        final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/face/single/add";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
 
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendpost(path, body,"0","添加人脸数据","0");// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 修改人脸数据
     * @param jsonBody
     * @return
     */
    public static JSONObject updatePersonFace(JSONObject jsonBody) {
        final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/face/single/update";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
 
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendpost(path, body,"0","修改人脸数据","0");// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 创建下载任务
     * @param taskType(下载任务类型 1:卡片 4:人脸)
     *
     * @return
     */
    public static JSONObject newTask(String taskType) {
        final String getCamsApi = ARTEMIS_PATH + "/api/acps/v1/authDownload/task/addition";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("taskType",taskType);
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendpost(path, body,"0","创建下载任务","0");// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 向下载任务中添加数据
     * @param jsonBody
     * @return
     */
    public static JSONObject addTaskData(JSONObject jsonBody) {
        final String getCamsApi = ARTEMIS_PATH + "/api/acps/v1/authDownload/data/addition";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendpost(path, body,"0","下载任务添加数据","0");// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 开始下载任务
     * @param taskId
     * @return
     */
    public static JSONObject startTask(String taskId) {
        final String getCamsApi = ARTEMIS_PATH + "/api/acps/v1/authDownload/task/start";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("taskId",taskId);
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendpost(path, body,"0","开始下载任务","0");// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 删除未开始的下载任务
     * @param taskId
     * @return
     */
    public static JSONObject deleteTask(String taskId) {
        final String getCamsApi = ARTEMIS_PATH + "/api/acps/v1/authDownload/task/deletion";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("taskId",taskId);
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendpost(path, body,"0","删除未开始下载任务","0");// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 查询下载任务进度
     * @param taskId
     * @return
     */
    public static JSONObject queryTask(String taskId) {
        final String getCamsApi = ARTEMIS_PATH + "/api/acps/v1/authDownload/task/progress";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("taskId",taskId);
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendpost(path, body,"0","查询下载任务进度","0");// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
 
    /**
     * 查询人员下载结果
     * @param jsonBody
     * @return
     */
    public static JSONObject queryPersonResult(JSONObject jsonBody) {
        final String getCamsApi = ARTEMIS_PATH + "/api/acps/v1/auth_item/list/search";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = sendpost(path, body,"0","查询人员下载结果","0");// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /*public static JSONArray getResourceInfos(List<LhDeviceDO> deviceList){
        JSONArray resourceInfos = new JSONArray();
        deviceList.forEach(v->{
            JSONObject deviceObject = new JSONObject();
            deviceObject.put("resourceIndexCode",v.getId());
            deviceObject.put("resourceType",v.getResourceType());
            String channelNo = v.getChannelNo();
            String[] c = channelNo.split(",");
            int[] array = Arrays.asList(c).stream().mapToInt(Integer::parseInt).toArray();
            JSONArray ca = new JSONArray();
            for (int i =0 ; i<array.length;i++) {
                ca.add(array[i]);
            }
            deviceObject.put("channelNos",ca);
            resourceInfos.add(deviceObject);
        });
        return resourceInfos;
    }*/
    /**
     * 分页获取监控点资源
     * @param page
     * @param rows
     * @return
     */
    public static JSONObject monitoryList(int page, int rows) {
        final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/cameras";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
        JSONObject jsonBody = new JSONObject();
 
        jsonBody.put("pageNo", page);
        jsonBody.put("pageSize", rows);
//        jsonBody.put("resourceType", "acsDevice");
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = null;
        try {
            result = sendpost(path, body,"0","分页获取监控点资源","1");
 
        } catch (Exception e) {
            e.printStackTrace();
        }
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
    /**
     * 分页获取监控点在线状态
     * @param page
     * @param rows
     * @return
     */
    public static JSONObject monitoryStatus(int page, int rows) {
        final String getCamsApi = ARTEMIS_PATH + "/api/nms/v1/online/camera/get";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
        JSONObject jsonBody = new JSONObject();
 
        jsonBody.put("pageNo", page);
        jsonBody.put("pageSize", rows);
 
//        List<String>list=new ArrayList<>();
//        list.add("1a3cb6e19fbc44d8b31ae74e29fb438d");
//        jsonBody.put("indexCodes", list);
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = null;
        try {
            result = sendpost(path, body,"0","分页获取监控点在线状态","1");
 
        } catch (Exception e) {
            e.printStackTrace();
        }
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 获取监控点预览取流URLv2
     * @param cameraIndexCode
     * @return
     */
    public static JSONObject monitoryPreview(String cameraIndexCode) {
        final String getCamsApi = ARTEMIS_PATH + "/api/video/v2/cameras/previewURLs";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
        JSONObject jsonBody = new JSONObject();
 
        jsonBody.put("cameraIndexCode", cameraIndexCode);
        jsonBody.put("streamType", "");
        jsonBody.put("protocol", "");
        jsonBody.put("transmode", "");
        jsonBody.put("expand", "");
        jsonBody.put("streamform", "");
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = null;
        try {
            result = sendpost(path, body,"0","获取监控点预览取流URLv2","0");
        } catch (Exception e) {
            e.printStackTrace();
        }
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 获取监控点回放
     * @param cameraIndexCode
     * @return
     */
    public static JSONObject monitoryBackview(String cameraIndexCode,String beginTime,String endTime) {
        final String getCamsApi = ARTEMIS_PATH + "/api/video/v2/cameras/playbackURLs";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
        JSONObject jsonBody = new JSONObject();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date startDate=null;
        Date endDate=null;
        try {
             startDate = sdf.parse(beginTime);
             endDate = sdf.parse(endTime);
        } catch (ParseException e) {
            e.printStackTrace();
        }
 
        jsonBody.put("cameraIndexCode", cameraIndexCode);
        jsonBody.put("recordLocation", "");
        jsonBody.put("protocol", "");
        jsonBody.put("transmode", "");
        jsonBody.put("uuid", "");
        jsonBody.put("expand", "");
        jsonBody.put("streamform", "");
        jsonBody.put("lockType", "");
        jsonBody.put("beginTime", getISO8601Timestamp(startDate));
        jsonBody.put("endTime", getISO8601Timestamp(endDate));
//        jsonBody.put("beginTime", "2021-12-15T00:00:00.000+08:00");
//        jsonBody.put("endTime", "2021-12-16T00:00:00.000+08:00");
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = null;
        try {
//            result = sendPost(path, body);
            result = sendpost(path, body,"0","获取监控点回放","0");
 
        } catch (Exception e) {
            e.printStackTrace();
        }
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * 云台操作
     * @param cameraIndexCode
     * @return
     */
    public static JSONObject yuntaiOperation(String cameraIndexCode,String action,String command,String speed) {
        final String getCamsApi = ARTEMIS_PATH + "/api/video/v1/ptzs/controlling";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
        JSONObject jsonBody = new JSONObject();
 
 
        jsonBody.put("cameraIndexCode", cameraIndexCode);
        jsonBody.put("action", action);
        jsonBody.put("command", command);
        jsonBody.put("speed", speed);
        jsonBody.put("presetIndex", "");
 
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = null;
        try {
            result = sendpost(path, body,"0","云台操作","0");
        } catch (Exception e) {
            e.printStackTrace();
        }
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
    }
 
    /**
     * type 0内部调用1外部调用
     * msg 方法名
     * flage 0走log日志 1不走
     * @param path
     * @param body
     * @param type
     * @return
     */
    private static String sendpost(Map<String, String> path, String body,String type,String msg,String flage) {
        String result = null;
        try {
            result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, "application/json", null);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if("0".equals(flage)){
//                    HkMonitoryLogDO hkMonitoryLogDO=new HkMonitoryLogDO();
//                    hkMonitoryLogDO.setId(UUID.randomUUID().toString());
//                    hkMonitoryLogDO.setMethodName(msg);
//                    hkMonitoryLogDO.setType(type);
//                    hkMonitoryLogDO.setCreateDate(new Date());
//
//                    hkMonitoryLogDO.setCreator("内部请求");
//                    hkMonitoryLogDO.setIsDeleted("0");
//                    hkMonitoryLogDO.setRequestData(body);
//                    hkMonitoryLogDO.setResponseData(result);
//                    hkMonitoryLogDO.setUrl(path.get("https://"));
//                    HkMonitoryLogService bean = SpringContextUtil.getBean(HkMonitoryLogService.class);
//                    int save = bean.save(hkMonitoryLogDO);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            return result;
        }
 
    }
 
 
    /**
     * 获取增量人员数据列表(删除,修改,新增)
     * @param page
     * @param rows
     * @param startTime
     * @param endTime
     * @return
     */
    public static JSONObject userChange(int page, int rows, String startTime, String endTime) {
        final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/person/personList/timeRange";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
        JSONObject jsonBody = new JSONObject();
 
        jsonBody.put("pageNo", page);
        jsonBody.put("pageSize", rows);
        jsonBody.put("startTime", startTime);
        jsonBody.put("endTime", endTime);
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, "application/json", null);// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
//        return JSONObject.parseObject("{\"code\":\"1\",\"msg\":\"HKUtil代码注释,功能关闭\"}");
    }
 
    /**
     * 获取增量人员数据列表(删除,修改,新增)
     * @param page
     * @param rows
     * @param startTime
     * @param endTime
     * @return
     */
    public static JSONObject orgChange(int page, int rows, String startTime, String endTime) {
        final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/org/timeRange";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
            }
        };
        JSONObject jsonBody = new JSONObject();
 
        jsonBody.put("pageNo", page);
        jsonBody.put("pageSize", rows);
        jsonBody.put("startTime", startTime);
        jsonBody.put("endTime", endTime);
        String body = jsonBody.toJSONString();
 
        logger.info(getCamsApi+"--->body参数:"+body);
        String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, "application/json", null);// post请求application/json类型参数
        logger.info(getCamsApi+"--->result参数:"+result);
        return JSONObject.parseObject(result);
//        return JSONObject.parseObject("{\"code\":\"1\",\"msg\":\"HKUtil代码注释,功能关闭\"}");
    }
 
 
    /**
     * 传入Data类型日期,返回字符串类型时间(ISO8601标准时间)
     * @param date
     * @return
     */
    public static String getISO8601Timestamp(Date date){
        TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai");
        //TimeZone tz = TimeZone.getTimeZone("GMT-01");
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
        df.setTimeZone(tz);
        String nowAsISO = df.format(date);
        return nowAsISO;
    }
 
}