zhangnaisong
2024-05-07 9b9af4c9457c03061ce4d0bb7656a2c3ad04894e
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
package com.ruoyi.alarmpoints.well.service.impl;
 
import java.awt.geom.Point2D;
import java.math.BigDecimal;
import java.sql.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.alarmpoints.well.domain.*;
import com.ruoyi.alarmpoints.well.mapper.ArdAlarmpointsWellMapper;
import com.ruoyi.alarmpoints.well.mapper.ArdWellGuideCameraMapper;
import com.ruoyi.alarmpoints.well.service.IArdAlarmpointsWellService;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.core.domain.entity.SysConfig;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanValidators;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.device.camera.domain.ArdCameras;
import com.ruoyi.device.camera.mapper.ArdCamerasMapper;
import com.ruoyi.device.tower.domain.ArdTowers;
import com.ruoyi.device.tower.mapper.ArdTowersMapper;
import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.utils.data.Query;
import com.ruoyi.utils.gis.GisUtil;
import com.ruoyi.utils.gps.GeoTools;
import lombok.ToString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import javax.annotation.Resource;
import javax.validation.Validator;
 
/**
 * 井管理Service业务层处理
 *
 * @author 刘苏义
 * @date 2023-03-07
 */
@Service
public class ArdAlarmpointsWellServiceImpl implements IArdAlarmpointsWellService {
    private static final Logger log = LoggerFactory.getLogger(ArdAlarmpointsWellServiceImpl.class);
    @Resource
    private ArdAlarmpointsWellMapper ardAlarmpointsWellMapper;
    @Resource
    private ArdWellGuideCameraMapper ardWellGuideCameraMapper;
    @Resource
    private ArdCamerasMapper ardCamerasMapper;
 
    @Resource
    private ArdTowersMapper ardTowersMapper;
 
    @Autowired
    protected Validator validator;
 
    @Resource
    protected SysDeptMapper sysDeptMapper;
 
    /**
     * 查询井管理
     *
     * @param id 井管理主键
     * @return 井管理
     */
    @Override
    public ArdAlarmpointsWell selectArdAlarmpointsWellById(String id) {
        return ardAlarmpointsWellMapper.selectArdAlarmpointsWellById(id);
    }
 
    /**
     * 查询井管理
     *
     * @param wellId 井管理主键
     * @return 井管理
     */
    @Override
    public ArdAlarmpointsWell selectArdAlarmpointsWellByWellId(String wellId) {
        return ardAlarmpointsWellMapper.selectArdAlarmpointsWellByWellId(wellId);
    }
 
    /**
     * 查询井管理列表
     *
     * @param ardAlarmpointsWell 井管理
     * @return 井管理
     */
    @Override
    @DataScope(deptAlias = "d", userAlias = "u")
    public List<ArdAlarmpointsWell> selectArdAlarmpointsWellList(ArdAlarmpointsWell ardAlarmpointsWell) {
        return ardAlarmpointsWellMapper.selectArdAlarmpointsWellList(ardAlarmpointsWell);
    }
 
    /**
     * @param ardAlarmpointsWell 按井编号查询
     * @return
     */
    @Override
    @DataScope(deptAlias = "d", userAlias = "u")
    public List<ArdAlarmpointsWell> selectArdAlarmpointsWellByWellIdLike(ArdAlarmpointsWell ardAlarmpointsWell) {
        return ardAlarmpointsWellMapper.selectArdAlarmpointsWellByWellIdLike(ardAlarmpointsWell);
    }
 
    /**
     * 新增井管理
     *
     * @param ardAlarmpointsWell 井管理
     * @return 结果
     */
    @Override
    @Transactional
    public int insertArdAlarmpointsWell(ArdAlarmpointsWell ardAlarmpointsWell) {
        boolean wellIdExists = checkWellIdExists(ardAlarmpointsWell);
        if (wellIdExists) {
            throw new RuntimeException("井号已存在");
        }
        ardAlarmpointsWell.setId(IdUtils.simpleUUID());
        ardAlarmpointsWell.setUserId(SecurityUtils.getUserId());
        ardAlarmpointsWell.setCreateBy(SecurityUtils.getUsername());
        ardAlarmpointsWell.setCreateTime(DateUtils.getNowDate());
        return ardAlarmpointsWellMapper.insertArdAlarmpointsWell(ardAlarmpointsWell);
    }
 
    /**
     * 修改井管理
     *
     * @param ardAlarmpointsWell 井管理
     * @return 结果
     */
    @Override
    @Transactional
    public int updateArdAlarmpointsWell(ArdAlarmpointsWell ardAlarmpointsWell) {
        boolean wellIdExists = checkWellIdExists(ardAlarmpointsWell);
        if (wellIdExists) {
            throw new RuntimeException("井号已存在");
        }
        ardAlarmpointsWell.setUpdateBy(SecurityUtils.getUsername());
        ardAlarmpointsWell.setUpdateTime(DateUtils.getNowDate());
        return ardAlarmpointsWellMapper.updateArdAlarmpointsWell(ardAlarmpointsWell);
    }
 
    @Override
    @Transactional
    public int updateArdAlarmpointsWellByWellId(ArdAlarmpointsWell ardAlarmpointsWell) {
        ardAlarmpointsWell.setUpdateBy(SecurityUtils.getUsername());
        ardAlarmpointsWell.setUpdateTime(DateUtils.getNowDate());
        return ardAlarmpointsWellMapper.updateArdAlarmpointsWellByWellId(ardAlarmpointsWell);
    }
 
    /**
     * 批量删除井管理
     *
     * @param ids 需要删除的井管理主键
     * @return 结果
     */
    @Override
    public int deleteArdAlarmpointsWellByIds(String[] ids) {
        return ardAlarmpointsWellMapper.deleteArdAlarmpointsWellByIds(ids);
    }
 
    /**
     * 删除井管理信息
     *
     * @param id 井管理主键
     * @return 结果
     */
    @Override
    public int deleteArdAlarmpointsWellById(String id) {
        return ardAlarmpointsWellMapper.deleteArdAlarmpointsWellById(id);
    }
 
    @Override
    public String importWell(List<ArdAlarmpointsWell> ardAlarmpointsWellList, Boolean isUpdateSupport, String operName) {
        if (StringUtils.isNull(ardAlarmpointsWellList) || ardAlarmpointsWellList.size() == 0) {
            throw new ServiceException("导入井数据不能为空!");
        }
        int successNum = 0;
        int failureNum = 0;
        StringBuilder successMsg = new StringBuilder();
        StringBuilder failureMsg = new StringBuilder();
        for (ArdAlarmpointsWell well : ardAlarmpointsWellList) {
            try {
                //获取当前登录用户id
                String userId = SecurityUtils.getUserId();
                well.setUserId(userId);
                // 验证是否存在这个井
                ArdAlarmpointsWell w = ardAlarmpointsWellMapper.selectArdAlarmpointsWellByWellId(well.getWellId());
                if (StringUtils.isNull(w)) {
                    BeanValidators.validateWithException(validator, well);
                    well.setCreateBy(operName);
                    this.insertArdAlarmpointsWell(well);
                    successNum++;
                    successMsg.append("<br/>" + successNum + "、井号 " + well.getWellId() + " 导入成功");
                } else if (isUpdateSupport) {
                    BeanValidators.validateWithException(validator, well);
                    checkWellDataScope(well.getUserId());
                    well.setUpdateBy(operName);
                    this.updateArdAlarmpointsWellByWellId(well);
                    successNum++;
                    successMsg.append("<br/>" + successNum + "、井号 " + well.getWellId() + " 更新成功");
                } else {
                    failureNum++;
                    failureMsg.append("<br/>" + failureNum + "、井号 " + well.getWellId() + " 已存在");
                }
            } catch (Exception e) {
                failureNum++;
                String msg = "<br/>" + failureNum + "、井号 " + well.getWellId() + " 导入失败:";
                failureMsg.append(msg + e.getMessage());
                log.error(msg, e);
            }
        }
        if (failureNum > 0) {
            failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
            throw new ServiceException(failureMsg.toString());
        } else {
            successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
        }
        return successMsg.toString();
    }
 
    /**
     * 校验井是否允许操作
     *
     * @param well 井信息
     */
    @Override
    public void checkWellAllowed(ArdAlarmpointsWell well) {
        if (StringUtils.isNotNull(well.getId())) {
            throw new ServiceException("不允许操作井");
        }
    }
 
    /**
     * 校验用户是否有数据权限
     *
     * @param userId 用户id
     */
    @Override
    public void checkWellDataScope(String userId) {
        if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
            ArdAlarmpointsWell well = new ArdAlarmpointsWell();
            well.setUserId(userId);
            List<ArdAlarmpointsWell> wells = SpringUtils.getAopProxy(this).selectArdAlarmpointsWellList(well);
            if (StringUtils.isEmpty(wells)) {
                throw new ServiceException("没有权限访问井数据!");
            }
        }
    }
 
    /**
     * 核对井号是否唯一
     *
     * @param well 需要核对的井
     * @return 结果
     */
    @Override
    public Boolean checkWellIdExists(ArdAlarmpointsWell well) {
        // 校验:wellId
        String id = (well.getId() == null) ? "" : well.getId();
        String wellId = well.getWellId();
        ArdAlarmpointsWell ardAlarmpointsWell = ardAlarmpointsWellMapper.checkWellIdExists(wellId);
        String infoId = (ardAlarmpointsWell == null) ? "" : (ardAlarmpointsWell.getId());
        if ((ardAlarmpointsWell != null) && !((infoId).equals(id))) {
            //已存在
            return true;
        }
        return false;
    }
 
    @Override
    public List<ArdAlarmpointsWell> wellByDeptList(List<Long> deptList) {
        QueryWrapper<ArdAlarmpointsWell> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("dept_id", deptList);
        return ardAlarmpointsWellMapper.selectList(queryWrapper);
    }
 
    @Override
    public ArdAlarmpointsWell wellById(String id) {
        return ardAlarmpointsWellMapper.selectById(id);
    }
 
    @Override
    public List<ArdAlarmpointsWell> wellList(List<Long> deptList) {
        QueryWrapper<ArdAlarmpointsWell> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("id", "well_id", "oil_production", "longitude", "latitude", "altitude").in("dept_id", deptList);
        return ardAlarmpointsWellMapper.selectList(queryWrapper);
    }
 
    @Override
    public PageInfo<ArdAlarmpointsWell> conditionList(ArdAlarmpointsWellParam ardAlarmpointsWellParam) {
        Integer pageNum = ardAlarmpointsWellParam.getPageNum();
        Integer pageSize = ardAlarmpointsWellParam.getPageSize();
        PageHelper.startPage(pageNum, pageSize);
        QueryWrapper<ArdAlarmpointsWell> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("id","altitude","metering_station","displacement_mode","latitude","dehydration_station",
                "well_type","production_date","well_id","transfer_station","oil_production","run_status","longitude",
                "installed_load","dept_id","user_id","surrounding_environment","well_number","well_block")
                .like(!StringUtils.isBlank(ardAlarmpointsWellParam.getWellId()), "well_id", ardAlarmpointsWellParam.getWellId())
                .in("dept_id", ardAlarmpointsWellParam.getDeptList());
        List<ArdAlarmpointsWell> list = ardAlarmpointsWellMapper.selectList(queryWrapper);
//        List<ArdAlarmpointsWell> list = ardAlarmpointsWellMapper.conditionList(ardAlarmpointsWellParam.getWellId(),ardAlarmpointsWellParam.getDeptList());
        return new PageInfo<>(list);
    }
 
    @Override
    public List<ArdAlarmpointsWellDeptVo> wellListDept(List<Long> deptList) {
        return ardAlarmpointsWellMapper.wellListDept(deptList);
    }
 
    @Override
    public List<ArdAlarmpointsWell> getNearbyWellList(Double longitudeCenter, Double latitudeCenter, Long deptId, Integer range) {
        List<ArdAlarmpointsWell> nearbyWellList = new ArrayList<>();
        try {
            if (longitudeCenter != null && latitudeCenter != null) {
                ArdAlarmpointsWell ardAlarmpointsWell = new ArdAlarmpointsWell();
                ardAlarmpointsWell.setDeptId(deptId);
                List<ArdAlarmpointsWell> ardAlarmpointsWells = ardAlarmpointsWellMapper.selectArdAlarmpointsWellList(ardAlarmpointsWell);
                if (ardAlarmpointsWells.size() > 0) {
                    for (ArdAlarmpointsWell well : ardAlarmpointsWells) {
                        Double longitude = well.getLongitude();
                        Double latitude = well.getLatitude();
                        if (longitude != null && latitude != null) {
                            double distance = GisUtil.getDistance(new Double[]{longitudeCenter, latitudeCenter}, new Double[]{longitude, latitude});
                            if (distance <= range) {
                                nearbyWellList.add(well);
                            }
                        }
                    }
                }
            }
        } catch (Exception ex) {
            log.error("获取附近井异常:" + ex.getMessage());
        }
        return nearbyWellList;
    }
 
    @Override
    public Map<String, Object> getWellDataByWellId(String wellId, List<SysConfig> config) {
        ArdAlarmpointsWell ardAlarmpointsWell = ardAlarmpointsWellMapper.selectArdAlarmpointsWellByWellId(wellId);
        Map<String, Object> result = new HashMap();
        if (ardAlarmpointsWell.getWellId() != null) {
            result.put("wellId", ardAlarmpointsWell.getWellId());
        } else {
            result.put("wellId", "");
        }
        if (ardAlarmpointsWell.getWellNumber() != null) {
            result.put("wellNumber", ardAlarmpointsWell.getWellNumber());
        } else {
            result.put("wellNumber", "");
        }
        if (ardAlarmpointsWell.getOilProduction() != null) {
            result.put("oilProduction", ardAlarmpointsWell.getOilProduction());
        } else {
            result.put("oilProduction", "");
        }
        if (ardAlarmpointsWell.getWellBlock() != null) {
            result.put("wellBlock", ardAlarmpointsWell.getWellBlock());
        } else {
            result.put("wellBlock", "");
        }
        if (ardAlarmpointsWell.getProductionDate() != null) {
            result.put("productionDate", ardAlarmpointsWell.getProductionDate());
        } else {
            result.put("productionDate", "");
        }
        if (ardAlarmpointsWell.getDisplacementMode() != null) {
            result.put("displacementMode", ardAlarmpointsWell.getDisplacementMode());
        } else {
            result.put("displacementMode", "");
        }
        if (ardAlarmpointsWell.getSurroundingEnvironment() != null) {
            result.put("surroundingEnvironment", ardAlarmpointsWell.getSurroundingEnvironment());
        } else {
            result.put("surroundingEnvironment", "");
        }
        if (ardAlarmpointsWell.getWellType() != null) {
            result.put("wellType", ardAlarmpointsWell.getWellType());
        } else {
            result.put("wellType", "");
        }
        if (ardAlarmpointsWell.getInstalledLoad() != null) {
            result.put("installedLoad", ardAlarmpointsWell.getInstalledLoad());
        } else {
            result.put("installedLoad", "");
        }
        if (ardAlarmpointsWell.getMeteringStation() != null) {
            result.put("meteringStation", ardAlarmpointsWell.getMeteringStation());
        } else {
            result.put("meteringStation", "");
        }
        if (ardAlarmpointsWell.getTransferStation() != null) {
            result.put("transferStation", ardAlarmpointsWell.getTransferStation());
        } else {
            result.put("transferStation", "");
        }
        if (ardAlarmpointsWell.getDehydrationStation() != null) {
            result.put("dehydrationStation", ardAlarmpointsWell.getDehydrationStation());
        } else {
            result.put("dehydrationStation", "");
        }
        if (ardAlarmpointsWell.getRunStatus() != null) {
            result.put("runStatus", ardAlarmpointsWell.getRunStatus());
        } else {
            result.put("runStatus", "");
        }
        if (ardAlarmpointsWell.getLongitude() != null) {
            result.put("longitude", ardAlarmpointsWell.getLongitude());
        } else {
            result.put("longitude", "");
        }
        if (ardAlarmpointsWell.getLatitude() != null) {
            result.put("latitude", ardAlarmpointsWell.getLatitude());
        } else {
            result.put("latitude", "");
        }
        if (ardAlarmpointsWell.getAltitude() != null) {
            result.put("altitude", ardAlarmpointsWell.getAltitude());
        } else {
            result.put("altitude", "");
        }
        if (ardAlarmpointsWell.getUserId() != null) {
            result.put("userId", ardAlarmpointsWell.getUserId());
        } else {
            result.put("userId", "");
        }
        if (ardAlarmpointsWell.getDeptId() != null) {
            result.put("deptId", ardAlarmpointsWell.getDeptId());
            SysDept sysDept = sysDeptMapper.selectDeptById(ardAlarmpointsWell.getDeptId());//查询兴趣点所在部门
            if (sysDept != null) {
                result.put("deptName", sysDept.getDeptName());
            } else {
                result.put("deptName", "");
            }
        } else {
            result.put("deptId", "");
            result.put("deptName", "");
        }
        if (ardAlarmpointsWell.getCreateBy() != null) {
            result.put("createBy", ardAlarmpointsWell.getCreateBy());
        } else {
            result.put("createBy", "");
        }
        if (ardAlarmpointsWell.getCreateTime() != null) {
            result.put("createTime", ardAlarmpointsWell.getCreateTime());
        } else {
            result.put("createTime", "");
        }
        if (ardAlarmpointsWell.getUpdateBy() != null) {
            result.put("updateBy", ardAlarmpointsWell.getUpdateBy());
        } else {
            result.put("updateBy", "");
        }
        if (ardAlarmpointsWell.getUpdateTime() != null) {
            result.put("updateTime", ardAlarmpointsWell.getUpdateTime());
        } else {
            result.put("updateTime", "");
        }
        if (config.size() != 0) {
            String oracle = config.get(0).getConfigValue();
            String[] oracleArr = oracle.split(";");
            if (oracleArr.length == 3) {
                String url = oracle.split(";")[0];
                String username = oracle.split(";")[1];
                String password = oracle.split(";")[2];
                try {
                    int checkMark = checkTable(url, username, password, "\'RTU_DATA_YJ_8\'");//三厂表存在
                    if (checkMark == 1) {
                        Map<String, Object> resultRTU = getRtuDataYjByJH(url, username, password, "RTU_DATA_YJ_8", "\'" + wellId + "\'");
                        result.putAll(resultRTU);
                    } else {
                        result.put("wellRunningState", "n");//油井运行状态
                        result.put("totalPowerConsumption", "n");//总耗电量
                        result.put("communicationMachine", "n");//设备通讯
                        result.put("remark", "n");//备注
                        result.put("singleWellWaterTemperature", "n");//单井掺水温度//
                        result.put("meteringPlantWaterPressure", "n");//计量间掺水压力//
                        result.put("torque", "n");//扭矩
                        result.put("MAT", "n");//回油温度
                        result.put("TGP", "n");//井口油压
                        result.put("CPV", "n");//井口套压
                        result.put("ADL", "n");//A相电流
                        result.put("ADY", "n");//A相电压
                        result.put("BDL", "n");//B相电流
                        result.put("BDY", "n");//B相电压
                        result.put("CDL", "n");//C相电流
                        result.put("CDY", "n");//C相电压
                        result.put("UCV", "n");//上行电流
                        result.put("DCV", "n");//下行电流
                        result.put("SLV", "n");//冲程
                        result.put("CHC", "n");//冲次
                        result.put("BPV", "n");//井口回压
                        result.put("ZWG", "n");//总无功功率
                        result.put("ZYG", "n");//总有功功率
                        result.put("GYS", "n");//功率因数
                        result.put("UWL", "n");//最大载荷
                        result.put("DWL", "n");//最小载荷
                        result.put("ZHS", "n");//转速
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else if (oracleArr.length == 4) {
                String url = oracle.split(";")[0];
                String username = oracle.split(";")[1];
                String password = oracle.split(";")[2];
                String prod = oracle.split(";")[3];
                try {
                    //int checkMark = checkTable(url,username,password,"\'RTU_DATA_YJ_8\'");//三厂表存在
                    int checkMark = checkTable(url, username, password, "\'" + prod + ".RTU_DATA_YJ_8\'");//三厂表存在
                    if (checkMark == 1) {
                        Map<String, Object> resultRTU = getRtuDataYjByJH(url, username, password, prod + ".RTU_DATA_YJ_8", "\'" + wellId + "\'");
                        result.putAll(resultRTU);
                    } else {
                        result.put("wellRunningState", "n");//油井运行状态
                        result.put("totalPowerConsumption", "n");//总耗电量
                        result.put("communicationMachine", "n");//设备通讯
                        result.put("remark", "n");//备注
                        result.put("singleWellWaterTemperature", "n");//单井掺水温度//
                        result.put("meteringPlantWaterPressure", "n");//计量间掺水压力//
                        result.put("torque", "n");//扭矩
                        result.put("MAT", "n");//回油温度
                        result.put("TGP", "n");//井口油压
                        result.put("CPV", "n");//井口套压
                        result.put("ADL", "n");//A相电流
                        result.put("ADY", "n");//A相电压
                        result.put("BDL", "n");//B相电流
                        result.put("BDY", "n");//B相电压
                        result.put("CDL", "n");//C相电流
                        result.put("CDY", "n");//C相电压
                        result.put("UCV", "n");//上行电流
                        result.put("DCV", "n");//下行电流
                        result.put("SLV", "n");//冲程
                        result.put("CHC", "n");//冲次
                        result.put("BPV", "n");//井口回压
                        result.put("ZWG", "n");//总无功功率
                        result.put("ZYG", "n");//总有功功率
                        result.put("GYS", "n");//功率因数
                        result.put("UWL", "n");//最大载荷
                        result.put("DWL", "n");//最小载荷
                        result.put("ZHS", "n");//转速
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        } else {
            result.put("wellRunningState", "n");//油井运行状态
            result.put("totalPowerConsumption", "n");//总耗电量
            result.put("communicationMachine", "n");//设备通讯
            result.put("remark", "n");//备注
            result.put("singleWellWaterTemperature", "n");//单井掺水温度//
            result.put("meteringPlantWaterPressure", "n");//计量间掺水压力//
            result.put("torque", "n");//扭矩
            result.put("MAT", "n");//回油温度
            result.put("TGP", "n");//井口油压
            result.put("CPV", "n");//井口套压
            result.put("ADL", "n");//A相电流
            result.put("ADY", "n");//A相电压
            result.put("BDL", "n");//B相电流
            result.put("BDY", "n");//B相电压
            result.put("CDL", "n");//C相电流
            result.put("CDY", "n");//C相电压
            result.put("UCV", "n");//上行电流
            result.put("DCV", "n");//下行电流
            result.put("SLV", "n");//冲程
            result.put("CHC", "n");//冲次
            result.put("BPV", "n");//井口回压
            result.put("ZWG", "n");//总无功功率
            result.put("ZYG", "n");//总有功功率
            result.put("GYS", "n");//功率因数
            result.put("UWL", "n");//最大载荷
            result.put("DWL", "n");//最小载荷
            result.put("ZHS", "n");//转速
        }
        return result;
    }
 
    @Override
    public Map<String, Object> getWellDataByPatrolplanIdAndPosition(Map<String, Object> para, List<SysConfig> config) {
        String patrolplanId = (String) para.get("patrolplanId");
        Double longitude = null;
        Double latitude = null;
        try{
            longitude = (Double) para.get("longitude");
            latitude = (Double) para.get("latitude");
        } catch (Exception e){
            longitude = ((BigDecimal) para.get("longitude")).doubleValue();
            latitude = ((BigDecimal) para.get("latitude")).doubleValue();
        }
        ArdAlarmpointsWell ardAlarmpointsWell = ardAlarmpointsWellMapper.getWellDataByPatrolplanIdAndPosition(patrolplanId,longitude,latitude);
        if(ardAlarmpointsWell != null){
            Map<String, Object> result = new HashMap();
            if (ardAlarmpointsWell.getWellId() != null) {
                result.put("wellId", ardAlarmpointsWell.getWellId());
            } else {
                result.put("wellId", "");
            }
            if (ardAlarmpointsWell.getWellNumber() != null) {
                result.put("wellNumber", ardAlarmpointsWell.getWellNumber());
            } else {
                result.put("wellNumber", "");
            }
            if (ardAlarmpointsWell.getOilProduction() != null) {
                result.put("oilProduction", ardAlarmpointsWell.getOilProduction());
            } else {
                result.put("oilProduction", "");
            }
            if (ardAlarmpointsWell.getWellBlock() != null) {
                result.put("wellBlock", ardAlarmpointsWell.getWellBlock());
            } else {
                result.put("wellBlock", "");
            }
            if (ardAlarmpointsWell.getProductionDate() != null) {
                result.put("productionDate", ardAlarmpointsWell.getProductionDate());
            } else {
                result.put("productionDate", "");
            }
            if (ardAlarmpointsWell.getDisplacementMode() != null) {
                result.put("displacementMode", ardAlarmpointsWell.getDisplacementMode());
            } else {
                result.put("displacementMode", "");
            }
            if (ardAlarmpointsWell.getSurroundingEnvironment() != null) {
                result.put("surroundingEnvironment", ardAlarmpointsWell.getSurroundingEnvironment());
            } else {
                result.put("surroundingEnvironment", "");
            }
            if (ardAlarmpointsWell.getWellType() != null) {
                result.put("wellType", ardAlarmpointsWell.getWellType());
            } else {
                result.put("wellType", "");
            }
            if (ardAlarmpointsWell.getInstalledLoad() != null) {
                result.put("installedLoad", ardAlarmpointsWell.getInstalledLoad());
            } else {
                result.put("installedLoad", "");
            }
            if (ardAlarmpointsWell.getMeteringStation() != null) {
                result.put("meteringStation", ardAlarmpointsWell.getMeteringStation());
            } else {
                result.put("meteringStation", "");
            }
            if (ardAlarmpointsWell.getTransferStation() != null) {
                result.put("transferStation", ardAlarmpointsWell.getTransferStation());
            } else {
                result.put("transferStation", "");
            }
            if (ardAlarmpointsWell.getDehydrationStation() != null) {
                result.put("dehydrationStation", ardAlarmpointsWell.getDehydrationStation());
            } else {
                result.put("dehydrationStation", "");
            }
            if (ardAlarmpointsWell.getRunStatus() != null) {
                result.put("runStatus", ardAlarmpointsWell.getRunStatus());
            } else {
                result.put("runStatus", "");
            }
            if (ardAlarmpointsWell.getLongitude() != null) {
                result.put("longitude", ardAlarmpointsWell.getLongitude());
            } else {
                result.put("longitude", "");
            }
            if (ardAlarmpointsWell.getLatitude() != null) {
                result.put("latitude", ardAlarmpointsWell.getLatitude());
            } else {
                result.put("latitude", "");
            }
            if (ardAlarmpointsWell.getAltitude() != null) {
                result.put("altitude", ardAlarmpointsWell.getAltitude());
            } else {
                result.put("altitude", "");
            }
            if (ardAlarmpointsWell.getUserId() != null) {
                result.put("userId", ardAlarmpointsWell.getUserId());
            } else {
                result.put("userId", "");
            }
            if (ardAlarmpointsWell.getDeptId() != null) {
                result.put("deptId", ardAlarmpointsWell.getDeptId());
                SysDept sysDept = sysDeptMapper.selectDeptById(ardAlarmpointsWell.getDeptId());//查询兴趣点所在部门
                if (sysDept != null) {
                    result.put("deptName", sysDept.getDeptName());
                } else {
                    result.put("deptName", "");
                }
            } else {
                result.put("deptId", "");
                result.put("deptName", "");
            }
            if (ardAlarmpointsWell.getCreateBy() != null) {
                result.put("createBy", ardAlarmpointsWell.getCreateBy());
            } else {
                result.put("createBy", "");
            }
            if (ardAlarmpointsWell.getCreateTime() != null) {
                result.put("createTime", ardAlarmpointsWell.getCreateTime());
            } else {
                result.put("createTime", "");
            }
            if (ardAlarmpointsWell.getUpdateBy() != null) {
                result.put("updateBy", ardAlarmpointsWell.getUpdateBy());
            } else {
                result.put("updateBy", "");
            }
            if (ardAlarmpointsWell.getUpdateTime() != null) {
                result.put("updateTime", ardAlarmpointsWell.getUpdateTime());
            } else {
                result.put("updateTime", "");
            }
            if (config.size() != 0) {
                String oracle = config.get(0).getConfigValue();
                String[] oracleArr = oracle.split(";");
                if (oracleArr.length == 3) {
                    String url = oracle.split(";")[0];
                    String username = oracle.split(";")[1];
                    String password = oracle.split(";")[2];
                    try {
                        int checkMark = checkTable(url, username, password, "\'RTU_DATA_YJ_8\'");//三厂表存在
                        if (checkMark == 1) {
                            Map<String, Object> resultRTU = getRtuDataYjByJH(url, username, password, "RTU_DATA_YJ_8", "\'" + ardAlarmpointsWell.getWellId() + "\'");
                            result.putAll(resultRTU);
                        } else {
                            result.put("wellRunningState", "n");//油井运行状态
                            result.put("totalPowerConsumption", "n");//总耗电量
                            result.put("communicationMachine", "n");//设备通讯
                            result.put("remark", "n");//备注
                            result.put("singleWellWaterTemperature", "n");//单井掺水温度//
                            result.put("meteringPlantWaterPressure", "n");//计量间掺水压力//
                            result.put("torque", "n");//扭矩
                            result.put("MAT", "n");//回油温度
                            result.put("TGP", "n");//井口油压
                            result.put("CPV", "n");//井口套压
                            result.put("ADL", "n");//A相电流
                            result.put("ADY", "n");//A相电压
                            result.put("BDL", "n");//B相电流
                            result.put("BDY", "n");//B相电压
                            result.put("CDL", "n");//C相电流
                            result.put("CDY", "n");//C相电压
                            result.put("UCV", "n");//上行电流
                            result.put("DCV", "n");//下行电流
                            result.put("SLV", "n");//冲程
                            result.put("CHC", "n");//冲次
                            result.put("BPV", "n");//井口回压
                            result.put("ZWG", "n");//总无功功率
                            result.put("ZYG", "n");//总有功功率
                            result.put("GYS", "n");//功率因数
                            result.put("UWL", "n");//最大载荷
                            result.put("DWL", "n");//最小载荷
                            result.put("ZHS", "n");//转速
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                } else if (oracleArr.length == 4) {
                    String url = oracle.split(";")[0];
                    String username = oracle.split(";")[1];
                    String password = oracle.split(";")[2];
                    String prod = oracle.split(";")[3];
                    try {
                        //int checkMark = checkTable(url,username,password,"\'RTU_DATA_YJ_8\'");//三厂表存在
                        int checkMark = checkTable(url, username, password, "\'" + prod + ".RTU_DATA_YJ_8\'");//三厂表存在
                        if (checkMark == 1) {
                            Map<String, Object> resultRTU = getRtuDataYjByJH(url, username, password, prod + ".RTU_DATA_YJ_8", "\'" + ardAlarmpointsWell.getWellId() + "\'");
                            result.putAll(resultRTU);
                        } else {
                            result.put("wellRunningState", "n");//油井运行状态
                            result.put("totalPowerConsumption", "n");//总耗电量
                            result.put("communicationMachine", "n");//设备通讯
                            result.put("remark", "n");//备注
                            result.put("singleWellWaterTemperature", "n");//单井掺水温度//
                            result.put("meteringPlantWaterPressure", "n");//计量间掺水压力//
                            result.put("torque", "n");//扭矩
                            result.put("MAT", "n");//回油温度
                            result.put("TGP", "n");//井口油压
                            result.put("CPV", "n");//井口套压
                            result.put("ADL", "n");//A相电流
                            result.put("ADY", "n");//A相电压
                            result.put("BDL", "n");//B相电流
                            result.put("BDY", "n");//B相电压
                            result.put("CDL", "n");//C相电流
                            result.put("CDY", "n");//C相电压
                            result.put("UCV", "n");//上行电流
                            result.put("DCV", "n");//下行电流
                            result.put("SLV", "n");//冲程
                            result.put("CHC", "n");//冲次
                            result.put("BPV", "n");//井口回压
                            result.put("ZWG", "n");//总无功功率
                            result.put("ZYG", "n");//总有功功率
                            result.put("GYS", "n");//功率因数
                            result.put("UWL", "n");//最大载荷
                            result.put("DWL", "n");//最小载荷
                            result.put("ZHS", "n");//转速
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            } else {
                result.put("wellRunningState", "n");//油井运行状态
                result.put("totalPowerConsumption", "n");//总耗电量
                result.put("communicationMachine", "n");//设备通讯
                result.put("remark", "n");//备注
                result.put("singleWellWaterTemperature", "n");//单井掺水温度//
                result.put("meteringPlantWaterPressure", "n");//计量间掺水压力//
                result.put("torque", "n");//扭矩
                result.put("MAT", "n");//回油温度
                result.put("TGP", "n");//井口油压
                result.put("CPV", "n");//井口套压
                result.put("ADL", "n");//A相电流
                result.put("ADY", "n");//A相电压
                result.put("BDL", "n");//B相电流
                result.put("BDY", "n");//B相电压
                result.put("CDL", "n");//C相电流
                result.put("CDY", "n");//C相电压
                result.put("UCV", "n");//上行电流
                result.put("DCV", "n");//下行电流
                result.put("SLV", "n");//冲程
                result.put("CHC", "n");//冲次
                result.put("BPV", "n");//井口回压
                result.put("ZWG", "n");//总无功功率
                result.put("ZYG", "n");//总有功功率
                result.put("GYS", "n");//功率因数
                result.put("UWL", "n");//最大载荷
                result.put("DWL", "n");//最小载荷
                result.put("ZHS", "n");//转速
            }
            return result;
        }else{
            return null;
        }
    }
 
    @Override
    public ArdAlarmpointsWell getWellById(String id) {
        ArdAlarmpointsWell result = ardAlarmpointsWellMapper.getWellById(id);
        return result;
    }
 
    @Override
    public List<Map<String, Object>> getCameraVideoLable(Long deptId, String cameraId, Float p, Float t, Float fHorFieldAngle, Float fVerFieldAngle) {
        ArdCameras ardCameras = ardCamerasMapper.selectArdCamerasById(cameraId);
        ArdTowers ardTowers = ardTowersMapper.selectArdTowersByCameraId(cameraId);
        if(ardTowers == null){
            return null;
        }
        //小三角形腰
        Double xy = Math.tan(Math.PI/2 - (Math.PI * 2 - Math.PI * t/180) - Math.PI * fVerFieldAngle/180/2)*ardCameras.getAltitude()/Math.cos(Math.PI * fHorFieldAngle/180/2);
        //大三角形腰
        Double dy = Math.tan(Math.PI/2 - (Math.PI * 2 - Math.PI * t/180) + Math.PI * fVerFieldAngle/180/2)*ardCameras.getAltitude()/Math.cos(Math.PI * fHorFieldAngle/180/2);
 
        if(dy < 0){
            dy = -1 * dy;
        }
 
        if(xy < 0){
            xy = -1 * xy;
        }
 
        Double lonA = ardCameras.getLongitude() + xy * Math.sin((p + fHorFieldAngle/2)* Math.PI / 180) * 180 / ( Math.PI * 6371229 * Math.cos(ardCameras.getLatitude() * Math.PI / 180));
        Double latA = ardCameras.getLatitude() + xy * Math.cos((p + fHorFieldAngle/2)* Math.PI / 180) / ( Math.PI * 6371229 / 180);
 
        System.out.println("A点经度:" + lonA);
        System.out.println("A点纬度:" + latA);
 
        Double lonB = ardCameras.getLongitude() + xy * Math.sin((p - fHorFieldAngle/2)* Math.PI / 180) * 180 / ( Math.PI * 6371229 * Math.cos(ardCameras.getLatitude() * Math.PI / 180));
        Double latB = ardCameras.getLatitude() + xy * Math.cos((p - fHorFieldAngle/2)* Math.PI / 180) / ( Math.PI * 6371229 / 180);
 
        System.out.println("B点经度:" + lonB);
        System.out.println("B点纬度:" + latB);
 
        Double lonC = ardCameras.getLongitude() + dy * Math.sin((p + fHorFieldAngle/2)* Math.PI / 180) * 180 / ( Math.PI * 6371229 * Math.cos(ardCameras.getLatitude() * Math.PI / 180));
        Double latC = ardCameras.getLatitude() + dy * Math.cos((p + fHorFieldAngle/2)* Math.PI / 180) / ( Math.PI * 6371229 / 180);
 
        System.out.println("C点经度:" + lonC);
        System.out.println("C点纬度:" + latC);
 
        Double lonD = ardCameras.getLongitude() + dy * Math.sin((p - fHorFieldAngle/2)* Math.PI / 180) * 180 / ( Math.PI * 6371229 * Math.cos(ardCameras.getLatitude() * Math.PI / 180));
        Double latD = ardCameras.getLatitude() + dy * Math.cos((p - fHorFieldAngle/2)* Math.PI / 180) / ( Math.PI * 6371229 / 180);
 
        System.out.println("D点经度:" + lonD);
        System.out.println("D点纬度:" + latD);
 
        Double dg = Math.tan(Math.PI/2 - (Math.PI * 2 - Math.PI * t/180) - Math.PI * fVerFieldAngle/180/2)*ardCameras.getAltitude();//大三角形高
        Double xg = Math.tan(Math.PI/2 - (Math.PI * 2 - Math.PI * t/180) + Math.PI * fVerFieldAngle/180/2)*ardCameras.getAltitude();//小三角形高
 
        if(dg < 0){
            dg = -1 * dg;
        }
 
        if(xg < 0){
            xg = -1 * xg;
        }
 
        Double mg = xg + 0.5 * (dg - xg);
 
        Double lonM = ardCameras.getLongitude() + mg * Math.sin(p * Math.PI / 180) * 180 / ( Math.PI * 6371229 * Math.cos(ardCameras.getLatitude() * Math.PI / 180));
        Double latM = ardCameras.getLatitude() + mg * Math.cos(p * Math.PI / 180) / ( Math.PI * 6371229 / 180);
        System.out.println("中点经度:" + lonM);
        System.out.println("中点纬度:" + latM);
        //根据部门及光轴地面投影等腰梯形中点获取兴趣点
        List<ArdAlarmpointsWell> ardAlarmpointsWellResult = ardAlarmpointsWellMapper.getArdAlarmpointsWellByDeptIdAndDistance(deptId, lonM, latM, lonA, latA, lonB, latB, lonC, latC, lonD, latD);
 
        //设置多边形
        List<Point2D.Double> pts = new ArrayList<Point2D.Double>();
        pts.add(new Point2D.Double(lonA, latA));
        pts.add(new Point2D.Double(lonB, latB));
        pts.add(new Point2D.Double(lonD, latD));
        pts.add(new Point2D.Double(lonC, latC));
 
        List<ArdAlarmpointsWell> innerList = new ArrayList();//查找多边形内兴趣点
        for(ArdAlarmpointsWell ardAlarmpointsWell : ardAlarmpointsWellResult){
            Point2D.Double point = new Point2D.Double(ardAlarmpointsWell.getLongitude(), ardAlarmpointsWell.getLatitude());
            if(GeoTools.IsPtInPoly(point, pts)){
                innerList.add(ardAlarmpointsWell);
            }
        }
 
        List<Map<String,Object>> result = new ArrayList();
 
        if(ardTowers.getAltitude() > 5){//有高程
            for(ArdAlarmpointsWell ardAlarmpointsWell : innerList){
                Map<String,Object> map = new HashMap();
                double distance_Target = RealDistance(ardCameras.getLongitude(),ardCameras.getLatitude(),ardAlarmpointsWell.getLongitude(), ardAlarmpointsWell.getLatitude());
 
                double Angle_A = GetAngle(ardCameras.getLongitude(),ardCameras.getLatitude(),ardAlarmpointsWell.getLongitude(), ardAlarmpointsWell.getLatitude());
                //double Angle_E = Math.atan((ardCameras.getAltitude() - 0) / distance_Target) * 180 / Math.PI;//无高程
                double Angle_E = Math.atan((ardCameras.getAltitude() + ardTowers.getAltitude() - ardAlarmpointsWell.getAltitude()) / distance_Target) * 180 / Math.PI;//有高程
 
                Angle_A = Angle_A - (p - fHorFieldAngle/2);//视场角内方位
                Angle_E = Angle_E - (360 - t - fVerFieldAngle/2);//视场角内俯仰
                if(!(Angle_E/fVerFieldAngle < 0.1 || Angle_A/fHorFieldAngle < 0.08 || Angle_A/fHorFieldAngle > 0.92)){//最上,最左,最右去掉
                    map.put("id",ardAlarmpointsWell.getId());
                    map.put("wellId",ardAlarmpointsWell.getWellId());
                    map.put("horFieldProportion",Angle_A/fHorFieldAngle);//横向占比
                    map.put("verFieldProportion",Angle_E/fVerFieldAngle);//纵向占比
                    result.add(map);
                }
            }
        }else{//无高程
            for(ArdAlarmpointsWell ardAlarmpointsWell : innerList){
                Map<String,Object> map = new HashMap();
                double distance_Target = RealDistance(ardCameras.getLongitude(),ardCameras.getLatitude(),ardAlarmpointsWell.getLongitude(), ardAlarmpointsWell.getLatitude());
 
                double Angle_A = GetAngle(ardCameras.getLongitude(),ardCameras.getLatitude(),ardAlarmpointsWell.getLongitude(), ardAlarmpointsWell.getLatitude());
                double Angle_E = Math.atan((ardCameras.getAltitude() - 0) / distance_Target) * 180 / Math.PI;//无高程
                //double Angle_E = Math.atan((ardCameras.getAltitude() + ardTowers.getAltitude() - ardAlarmpointsWell.getAltitude()) / distance_Target) * 180 / Math.PI;//有高程
 
                Angle_A = Angle_A - (p - fHorFieldAngle/2);//视场角内方位
                Angle_E = Angle_E - (360 - t - fVerFieldAngle/2);//视场角内俯仰
                if(!(Angle_E/fVerFieldAngle < 0.1 || Angle_A/fHorFieldAngle < 0.08 || Angle_A/fHorFieldAngle > 0.92)){//最上,最左,最右去掉
                    map.put("id",ardAlarmpointsWell.getId());
                    map.put("wellId",ardAlarmpointsWell.getWellId());
                    map.put("horFieldProportion",Angle_A/fHorFieldAngle);//横向占比
                    map.put("verFieldProportion",Angle_E/fVerFieldAngle);//纵向占比
                    result.add(map);
                }
            }
        }
 
 
        return result;
    }
 
    public static double RealDistance(double base_pos_longitude,double base_pos_latitude,double tar_pos_longitude,double tar_pos_latitude){
        double er;
        double f;
        double g;
        double l;
        double sg;
        double sl;
        double sf;
        double s;
        double c;
        double w;
        double r;
        double d;
        double h1;
        double h2;
        double fl;
 
        er = 6378.137;
        fl = 1 / 298.257;
        f = (base_pos_latitude + tar_pos_latitude)*Math.PI/360;
        g = (base_pos_latitude - tar_pos_latitude)*Math.PI/360;
        l = (base_pos_longitude - tar_pos_longitude)*Math.PI/360;
 
        sg = Math.sin(g);
        sl = Math.sin(l);
        sf = Math.sin(f);
 
        sg = Math.pow(sg,2);
        sl = Math.pow(sl,2);
        sf = Math.pow(sf,2);
 
        s = sg * (1 - sl) + (1 - sf) * sl;
        c = (1 - sg) * (1 - sl) + sf * sl;
 
        w = Math.atan(Math.sqrt(s / c));
        r = Math.sqrt(s * c) / w;
        d = 2 * w * er;
        h1 = (3 * r - 1) / 2 / c;
        h2 = (3 * r + 1) / 2 / s;
 
        return 1000*d * (1 + fl * (h1 * sf * (1 - sg) - h2 * (1 - sf) * sg));//84
    }
 
    public static double GetAngle(double base_pos_longitude,double base_pos_latitude,double tar_pos_longitude,double tar_pos_latitude){
        double lat1 = base_pos_latitude * Math.PI / 180;
        double lon1 = base_pos_longitude * Math.PI / 180;
        double lat2 = tar_pos_latitude * Math.PI / 180;
        double lon2 = tar_pos_longitude * Math.PI / 180;
        double d = Math.sin(lat2)*Math.sin(lat1) + Math.cos(lat2)*Math.cos(lat1)*Math.cos(lon2 - lon1);
        if (d != 1){
            d = Math.asin(Math.cos(lat2) * Math.sin(lon2 - lon1) / Math.sqrt(1 - d * d));
            d = d * 180 / Math.PI;
        }
        else {
            d = 0;
        }
        if (lat1>lat2) {
            d = 180 - d;
        }
        else {
            if (lon1>lon2) {
                d = 360 + d;
            }
        }
        return d;
    }
 
    public int checkTable(String url, String username, String password, String tableName) throws ClassNotFoundException, SQLException {
        Connection connection = null;
 
        Statement updateStatement = null;
 
        Statement queryStatement = null;
 
        try {
            Class.forName("oracle.jdbc.OracleDriver");
            connection = DriverManager.getConnection(url, username, password);
            //Statement 对象 发送sql
            updateStatement = connection.createStatement();
            //查询
            queryStatement = connection.createStatement();
            ResultSet resultSet = queryStatement.executeQuery("select count(*) from user_tables where table_name = upper(" + tableName + ")");
 
            int result = 0;
            while (resultSet.next()) {
                int column = resultSet.getInt(1);
                result = column;
            }
            return result;
        } catch (SQLException e) {
            e.printStackTrace();
            return 0;
        } finally {
            if (updateStatement != null) {
                updateStatement.close();
            }
            if (queryStatement != null) {
                queryStatement.close();
            }
            if (connection != null) {
                connection.close();
            }
        }
    }
 
    public Map<String, Object> getRtuDataYjByJH(String url, String username, String password, String tableName, String JH) throws ClassNotFoundException, SQLException {
        Connection connection = null;
 
        Statement updateStatement = null;
 
        Statement queryStatement = null;
 
        try {
            Class.forName("oracle.jdbc.OracleDriver");
            connection = DriverManager.getConnection(url, username, password);
            //Statement 对象 发送sql
            updateStatement = connection.createStatement();
            //查询
            queryStatement = connection.createStatement();
            ResultSet resultSet = queryStatement.executeQuery("select rdy0.* from " + tableName + " rdy0 inner join (" +
                    "select rdy.JH,max(rdy.RQ) as RQ from RTU_DATA_YJ_8 rdy group by rdy.JH" +
                    ")t on rdy0.JH = t.JH and rdy0.RQ = t.RQ where rdy0.JH = " + JH);
 
            Map<String, Object> result = new HashMap();
            while (resultSet.next()) {
                result.put("wellRunningState", "n");
                result.put("totalPowerConsumption", "n");//总耗电量
                result.put("communicationMachine", "n");//设备通讯
                result.put("remark", "n");//备注
                result.put("singleWellWaterTemperature", "n");//单井掺水温度//
                result.put("meteringPlantWaterPressure", "n");//计量间掺水压力//
                result.put("torque", "n");//扭矩
 
                if (resultSet.getString("MAT") != null) {//回油温度
                    result.put("MAT", resultSet.getString("MAT"));
                } else {
                    result.put("MAT", "n");
                }
                if (resultSet.getString("TGP") != null) {//井口油压
                    result.put("TGP", resultSet.getString("TGP"));
                } else {
                    result.put("TGP", "n");
                }
                if (resultSet.getString("CPV") != null) {//井口套压
                    result.put("CPV", resultSet.getString("CPV"));
                } else {
                    result.put("CPV", "n");
                }
                if (resultSet.getString("ADL") != null) {//A相电流
                    result.put("ADL", resultSet.getString("ADL"));
                } else {
                    result.put("ADL", "n");
                }
                if (resultSet.getString("ADY") != null) {//A相电压
                    result.put("ADY", resultSet.getString("ADY"));
                } else {
                    result.put("ADY", "n");
                }
                if (resultSet.getString("BDL") != null) {//B相电流
                    result.put("BDL", resultSet.getString("BDL"));
                } else {
                    result.put("BDL", "n");
                }
                if (resultSet.getString("BDY") != null) {//B相电压
                    result.put("BDY", resultSet.getString("BDY"));
                } else {
                    result.put("BDY", "n");
                }
                if (resultSet.getString("CDL") != null) {//C相电流
                    result.put("CDL", resultSet.getString("CDL"));
                } else {
                    result.put("CDL", "n");
                }
                if (resultSet.getString("CDY") != null) {//C相电压
                    result.put("CDY", resultSet.getString("CDY"));
                } else {
                    result.put("CDY", "n");
                }
                if (resultSet.getString("UCV") != null) {//上行电流
                    result.put("UCV", resultSet.getString("UCV"));
                } else {
                    result.put("UCV", "n");
                }
                if (resultSet.getString("DCV") != null) {//下行电流
                    result.put("DCV", resultSet.getString("DCV"));
                } else {
                    result.put("DCV", "n");
                }
                if (resultSet.getString("SLV") != null) {//冲程
                    result.put("SLV", resultSet.getString("SLV"));
                } else {
                    result.put("SLV", "n");
                }
                if (resultSet.getString("CHC") != null) {//冲次
                    result.put("CHC", resultSet.getString("CHC"));
                } else {
                    result.put("CHC", "n");
                }
                if (resultSet.getString("BPV") != null) {//井口回压
                    result.put("BPV", resultSet.getString("BPV"));
                } else {
                    result.put("BPV", "n");
                }
                if (resultSet.getString("ZWG") != null) {//总无功功率
                    result.put("ZWG", resultSet.getString("ZWG"));
                } else {
                    result.put("ZWG", "n");
                }
                if (resultSet.getString("ZYG") != null) {//总有功功率
                    result.put("ZYG", resultSet.getString("ZYG"));
                } else {
                    result.put("ZYG", "n");
                }
                if (resultSet.getString("GYS") != null) {//功率因数
                    result.put("GYS", resultSet.getString("GYS"));
                } else {
                    result.put("GYS", "n");
                }
                if (resultSet.getString("UWL") != null) {//最大载荷
                    result.put("UWL", resultSet.getString("UWL"));
                } else {
                    result.put("UWL", "n");
                }
                if (resultSet.getString("DWL") != null) {//最小载荷
                    result.put("DWL", resultSet.getString("DWL"));
                } else {
                    result.put("DWL", "n");
                }
                if (resultSet.getString("ZHS") != null) {//转速
                    result.put("ZHS", resultSet.getString("ZHS"));
                } else {
                    result.put("ZHS", "n");
                }
            }
            if (result.size() == 0) {
                result.put("wellRunningState", "n");//油井运行状态
                result.put("totalPowerConsumption", "n");//总耗电量
                result.put("communicationMachine", "n");//设备通讯
                result.put("remark", "n");//备注
                result.put("singleWellWaterTemperature", "n");//单井掺水温度//
                result.put("meteringPlantWaterPressure", "n");//计量间掺水压力//
                result.put("torque", "n");//扭矩
                result.put("MAT", "n");//回油温度
                result.put("TGP", "n");//井口油压
                result.put("CPV", "n");//井口套压
                result.put("ADL", "n");//A相电流
                result.put("ADY", "n");//A相电压
                result.put("BDL", "n");//B相电流
                result.put("BDY", "n");//B相电压
                result.put("CDL", "n");//C相电流
                result.put("CDY", "n");//C相电压
                result.put("UCV", "n");//上行电流
                result.put("DCV", "n");//下行电流
                result.put("SLV", "n");//冲程
                result.put("CHC", "n");//冲次
                result.put("BPV", "n");//井口回压
                result.put("ZWG", "n");//总无功功率
                result.put("ZYG", "n");//总有功功率
                result.put("GYS", "n");//功率因数
                result.put("UWL", "n");//最大载荷
                result.put("DWL", "n");//最小载荷
                result.put("ZHS", "n");//转速
            }
            return result;
        } finally {
            if (updateStatement != null) {
                updateStatement.close();
            }
            if (queryStatement != null) {
                queryStatement.close();
            }
            if (connection != null) {
                connection.close();
            }
        }
    }
 
}