王飞
2025-01-23 2de56e472a41b7feb90be29a54a2d6f5a6c8762e
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
package com.hxzkappboot.controller;
 
import com.hxzkappboot.pojo.GpsGuiJi;
import com.hxzkappboot.pojo.TbMarsHomeset;
import com.hxzkappboot.service.GpsGuiJiService;
import com.hxzkappboot.service.TbMarsHomesetService;
import com.hxzkappboot.util.GnssToXY;
import com.hxzkappboot.util.R;
import com.hxzkappboot.util.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
 
@RestController
//@RequestMapping("/")
public class GpsGuiJiController {
    
    private Integer tps = 0;
    
    @Autowired
    GpsGuiJiService gpsGuiJiService;
 
    @Autowired
    TbMarsHomesetService marsHomeSetService;
    
//    @Autowired
//    SettingService settingService;
 
//    @GetMapping("findGuiJiTrack")
//    result<List<TbGuiJiTrack>> findshishigaojing(Integer page, Integer limit){
//        LocalDate currentDate = LocalDate.now();
//        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
//        String formattedDate = currentDate.format(formatter);
//        PageInfo<TbGuiJiTrack> cz= gpsGuiJiService.findAll(page,limit,formattedDate);
//        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
//    }
 
 
    @GetMapping({"/api/wx/findBaiDuGuiJi"})
 
    R findBaiDuGuiJi(String tagid, String start, String end, String layer) throws ParseException {
        R response ;
        response = new R(StatusCode.Success);
        new ArrayList();
        List gui;
        if (layer.equals("默认地图")) {
            gui = this.gpsGuiJiService.findGuiJi(tagid, start, end);
        } else {
            gui = this.gpsGuiJiService.findGuiJiFloor(tagid, start, end, layer);
        }
 
        List<TbMarsHomeset> disTime = this.marsHomeSetService.findDistanceAndTime();
        Integer distance = Integer.valueOf(((TbMarsHomeset)disTime.get(0)).getDistance());
        response.setData(this.addHashMap(gui, distance * 100, Integer.parseInt(((TbMarsHomeset)disTime.get(0)).getTime())));
        return response;
    }
 
 
    public String gettime(){
        Date now = new Date();
        // 创建日期格式化对象,设置格式为 "yyyy-MM-dd HH:mm"
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        // 格式化日期对象,输出字符串结果
        String formattedDate = sdf.format(now);
        return formattedDate;
    }
 
    public static double[] gpstodu(String gps_weidu, String gps_jingdu) {
        double[] a = new double[]{0.0, 0.0};
        String weidu = todufen(gps_weidu.substring(0, 2), gps_weidu.substring(2, 4), gps_weidu.substring(4));
        String jingdu = todufen(gps_jingdu.substring(0, 3), gps_jingdu.substring(3, 5), gps_jingdu.substring(5));
        a[0] = Double.parseDouble(weidu);
        a[1] = Double.parseDouble(jingdu);
        return a;
    }
 
    private Map<Integer, List<GpsGuiJi>> addHashMap(List<GpsGuiJi> list, int pointDis, int timeC) {
        String latPast = "";
        String lonPast = "";
        String timePast = "";
        Map<Integer, List<GpsGuiJi>> map = new HashMap();
        List<GpsGuiJi> vector = null;
        int key = 0;
        int i = 0;
 
        String time;
        for(Iterator var11 = list.iterator(); var11.hasNext(); timePast = time) {
            GpsGuiJi info = (GpsGuiJi)var11.next();
            String lat = info.getGpsWeidu();
            String lon = info.getGspJingdu();
            time = info.getAddtime();
            if (latPast.length() > 0 && timePast.length() > 0) {
                int distance = GnssToXY.distance(lon, lat, lonPast, latPast);
                long cha = calculateTimeDifferenceInSeconds(timePast, time);
                if (distance < pointDis && cha < (long)timeC) {
                    vector.add(info);
                } else if (cha > (long)timeC) {
                    vector = new ArrayList();
                    map.put(key, vector);
                    vector.add(info);
                    ++key;
                } else if (distance > pointDis && cha < (long)timeC) {
                    vector = new ArrayList();
                    map.put(key, vector);
                    vector.add(info);
                    ++key;
                }
            } else {
                vector = new ArrayList();
                vector.add(info);
                map.put(key, vector);
                ++key;
            }
 
            latPast = lat;
            lonPast = lon;
        }
 
        return map;
    }
 
    public static long calculateTimeDifferenceInSeconds(String timeStr1, String timeStr2) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
        LocalDateTime time1 = LocalDateTime.parse(timeStr1, formatter);
        LocalDateTime time2 = LocalDateTime.parse(timeStr2, formatter);
        Duration duration = Duration.between(time1, time2);
        return duration.getSeconds();
    }
 
    public static String todufen(String Du, String Fen, String Miao) {
        Float strDu = Float.valueOf(Du);
        Float strFen = Float.valueOf(Fen) / 60.0F;
        Float strMiao = Float.valueOf(Miao) / 60.0F;
        Float dufenmiao = strDu + strFen + strMiao;
        String format = String.format("%.6f", dufenmiao);
        return format;
    }
//    public void Languages(){
//        List<TbSetting> setting = settingService.FindSetting();
//        if (setting.get(0).getLanguages().equals("0")){
//           tps = 0;
//        }
//        if (setting.get(0).getLanguages().equals("2")){
//            tps = 2;
//        }
//    }
}