yzt
2023-05-26 2f70f6727314edd84d8ec2bfe3ce832803f1ea77
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
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
 
package com.hxzkoa.controller;
 
import com.hxzkoa.json.tb_person;
import com.hxzkoa.json.tb_realocation;
import com.hxzkoa.json.tb_tag;
import com.hxzkoa.json.tb_track;
import com.hxzkoa.services.BasicInfoService;
import com.hxzkoa.services.LocationService;
import com.hxzkoa.util.Config;
import com.hxzkoa.util.ExcelUtils;
import com.hxzkoa.util.ModifyConfig;
import com.hxzkoa.util.PageUtil;
import com.hxzkoa.util.RequestUtils;
import java.io.IOException;
import java.io.OutputStream;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
 
@Controller
public class LocationController {
    @Autowired
    private LocationService locationService;
    @Autowired
    private BasicInfoService basicInfoService;
 
    public LocationController() {
    }
 
    @RequestMapping(
            value = {"/realTimeLocation.do"},
            method = {RequestMethod.POST, RequestMethod.GET}
    )
    public String realTimeLocation(HttpServletRequest request) {
        String toPage = "forward:/hxzk/location/realTimeLocation.jsp";
        List<tb_person> personManagement = this.basicInfoService.getPersonManagement(1);
        request.setAttribute("realTimeLocationList", personManagement);
        int curPage = 1;
        int count = this.basicInfoService.getPersonManagementCount();
        int minPage = PageUtil.getMinPage(count);
        request.setAttribute("pageList", PageUtil.getPage(minPage));
        request.setAttribute("curPage", Integer.valueOf(curPage));
        return toPage;
    }
 
    @ResponseBody
    @RequestMapping(
            value = {"/realTimeLocation_search.do"},
            method = {RequestMethod.POST, RequestMethod.GET}
    )
    public String realTimeLocation_search(HttpServletRequest request) {
        String input = request.getParameter("input");
        int curPage = 1;
        List<Integer> pageList = new ArrayList();
        List<tb_person> realTimeLocationList = this.basicInfoService.searchPersonManagement(input);
        pageList.add(1);
        JSONObject json = new JSONObject();
        json.put("dataList", realTimeLocationList);
        json.put("pageList", pageList);
        json.put("curPage", Integer.valueOf(curPage));
        return json.toString();
    }
 
    @ResponseBody
    @RequestMapping(
            value = {"/realTimeLocation_page.do"},
            method = {RequestMethod.POST, RequestMethod.GET}
    )
    public String realTimeLocation_page(HttpServletRequest request) {
        String pageStr = request.getParameter("page");
        String curPageStr = request.getParameter("curPage");
        int count = this.basicInfoService.getPersonManagementCount();
        int minPage = PageUtil.getMinPage(count);
        int curPage = Integer.parseInt(curPageStr);
        int page = 1;
        if ("pre".equals(pageStr)) {
            if (curPage > 1) {
                page = curPage - 1;
            }
        } else if ("next".equals(pageStr)) {
            if (curPage < minPage) {
                page = curPage + 1;
            }
        } else {
            page = Integer.parseInt(pageStr);
        }
 
        List<tb_person> realTimeLocationList = this.basicInfoService.getPersonManagement(page);
        List<Integer> pageList = PageUtil.getPage(PageUtil.getLocPage(page, curPage), page, minPage);
        JSONObject json = new JSONObject();
        json.put("dataList", realTimeLocationList);
        json.put("pageList", pageList);
        json.put("curPage", page);
        return json.toString();
    }
 
    @RequestMapping(
            value = {"/historicalLocation.do"},
            method = {RequestMethod.POST, RequestMethod.GET}
    )
    public String historicalLocation(HttpServletRequest request) throws SQLException {
        String toPage = "forward:/hxzk/location/historicalLocation.jsp";
        String pagePath = Config.getPageConfig();
        Integer perPage = Integer.parseInt(ModifyConfig.readData(pagePath, "perPage"));
        Date date = new Date(System.currentTimeMillis());
        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
        String currentDate = formatter.format(date);
        List<tb_track> trackList = this.locationService.getTrack(currentDate, 1, perPage);
        request.setAttribute("historicalLocationList", trackList);
        int curPage = 1;
        int count = this.locationService.getRealTimeLocationCount(currentDate);
        int minPage = PageUtil.getMinPage(count);
        request.setAttribute("pageList", PageUtil.getPage(minPage));
        request.setAttribute("curPage", Integer.valueOf(curPage));
        request.setAttribute("perPage", perPage);
        List<String> trackDateList = this.locationService.getTrackDateList();
        List<String> trackDateReList = new ArrayList();
        trackDateReList.add(currentDate);
 
        for(int i = 0; i < trackDateList.size(); ++i) {
            String listdate = (String)trackDateList.get(i);
            if (!currentDate.equals(listdate)) {
                trackDateReList.add(listdate);
            }
        }
 
        request.setAttribute("dateList", trackDateReList);
        return toPage;
    }
 
    @ResponseBody
    @RequestMapping(
            value = {"/historicalLocationa.do"},
            method = {RequestMethod.POST, RequestMethod.GET}
    )
    public JSONObject historicalLocationa(HttpServletRequest request) throws SQLException {
        JSONObject json = new JSONObject();
        String date = request.getParameter("date");
        int aaa = this.locationService.searchtablenameLocation("tb_track_" + date);
        if (aaa != 0) {
            List<tb_track> trackList = this.locationService.getTracka(date);
            json.put("dataList", trackList);
        } else {
            List<tb_track> trackList = new ArrayList();
            json.put("dataList", trackList);
        }
 
        return json;
    }
 
    @ResponseBody
    @RequestMapping(
            value = {"/historicalLocation_delete.do"},
            method = {RequestMethod.POST, RequestMethod.GET}
    )
    public void historicalLocation_delete(HttpServletRequest request) {
        String checkValStr = request.getParameter("checkVal");
        String date = request.getParameter("datea");
        checkValStr = checkValStr.replaceAll("\"", "");
        String[] checkVal = checkValStr.split(",");
        this.locationService.realTimeLocation_delete(checkVal, date);
    }
 
    @ResponseBody
    @RequestMapping(
            value = {"/historicalLocation_deletea.do"},
            method = {RequestMethod.POST, RequestMethod.GET}
    )
    public int historicalLocation_deletea(HttpServletRequest request) {
        String checkValStr = request.getParameter("checkVal");
        String date = request.getParameter("datea");
        checkValStr = checkValStr.replaceAll("\"", "");
        String[] checkVal = checkValStr.split(",");
        int bbb = this.locationService.searchtablenameLocation("tb_track_" + date);
        int aaa = 0;
        if (bbb != 0) {
            aaa = this.locationService.realTimeLocation_deletea(checkVal, date);
        }
 
        return aaa;
    }
 
    @ResponseBody
    @RequestMapping(
            value = {"/historicalLocation_deleteAll.do"},
            method = {RequestMethod.POST, RequestMethod.GET}
    )
    public void historicalLocation_deleteAll(HttpServletRequest request) {
        String date = request.getParameter("aaaa");
        this.locationService.realTimeLocation_deleteAll(date);
    }
 
    @ResponseBody
    @RequestMapping(
            value = {"/historicalLocation_deleteAlla.do"},
            method = {RequestMethod.POST, RequestMethod.GET}
    )
    public int historicalLocation_deleteAlla(HttpServletRequest request) {
        String date = request.getParameter("date");
        int bbb = this.locationService.searchtablenameLocation("tb_track_" + date);
        int aaa = 0;
        if (bbb != 0) {
            aaa = this.locationService.realTimeLocation_deleteAlla(date);
        }
 
        return aaa;
    }
 
    @ResponseBody
    @RequestMapping(
            value = {"/historicalLocation_search.do"},
            method = {RequestMethod.POST, RequestMethod.GET}
    )
    public String historicalLocation_search(HttpServletRequest request) {
        String input = request.getParameter("input");
        String date = request.getParameter("cccc");
        int curPage = 1;
        List<Integer> pageList = new ArrayList();
        List<tb_realocation> historicalLocationList = this.locationService.searchRealTimeLocation(input, date);
        pageList.add(1);
        JSONObject json = new JSONObject();
        json.put("dataList", historicalLocationList);
        json.put("pageList", pageList);
        json.put("curPage", Integer.valueOf(curPage));
        return json.toString();
    }
 
    @ResponseBody
    @RequestMapping(
            value = {"/historicalLocation_searcha.do"},
            method = {RequestMethod.POST, RequestMethod.GET}
    )
    public JSONObject historicalLocation_searcha(HttpServletRequest request) {
        String input = request.getParameter("tagid");
        String date = request.getParameter("date");
        JSONObject json = new JSONObject();
        int aaa = this.locationService.searchtablenameLocation("tb_track_" + date);
        if (aaa != 0) {
            List<tb_realocation> historicalLocationList = this.locationService.searchRealTimeLocation(input, date);
            json.put("dataList", historicalLocationList);
        } else {
            List<tb_realocation> abc = new ArrayList();
            json.put("dataList", abc);
        }
 
        return json;
    }
 
    @ResponseBody
    @RequestMapping(
            value = {"/historicalLocation_page.do"},
            method = {RequestMethod.POST, RequestMethod.GET}
    )
    public String historicalLocation_page(HttpServletRequest request) {
        String pageStr = request.getParameter("page");
        String curPageStr = request.getParameter("curPage");
        String date = request.getParameter("date");
        int count = this.locationService.getRealTimeLocationCount(date);
        int minPage = PageUtil.getMinPage(count);
        int curPage = Integer.parseInt(curPageStr);
        String pagePath = Config.getPageConfig();
        Integer perPage = Integer.parseInt(ModifyConfig.readData(pagePath, "perPage"));
        if ("".equals(pageStr) || pageStr == null) {
            pageStr = curPageStr;
        }
 
        int page = 1;
        if ("pre".equals(pageStr)) {
            if (curPage > 1) {
                page = curPage - 1;
            }
        } else if ("next".equals(pageStr)) {
            if (curPage < minPage) {
                page = curPage + 1;
            }
        } else {
            page = Integer.parseInt(pageStr);
        }
 
        List<tb_track> trackList = this.locationService.getTrack(date, page, perPage);
        List<Integer> pageList = PageUtil.getPage(PageUtil.getLocPage(page, curPage), page, minPage);
        JSONObject json = new JSONObject();
        json.put("dataList", trackList);
        json.put("pageList", pageList);
        json.put("curPage", page);
        return json.toString();
    }
 
    @ResponseBody
    @RequestMapping(
            value = {"/historicalLocation_export.do"},
            method = {RequestMethod.POST, RequestMethod.GET}
    )
    public String historicalPower_export(HttpServletRequest request, HttpServletResponse response) {
        String toPage = "forward:/hxzk/label/historicalLocation.jsp";
        Enumeration<String> paraNames = request.getParameterNames();
        String thisName = null;
        String thisValue = null;
 
        for(Enumeration<String> e = paraNames; e.hasMoreElements(); thisValue = request.getParameter(thisName)) {
            thisName = (String)e.nextElement() + "";
        }
 
        List<tb_realocation> historicalLocationList = this.locationService.getRealTimeLocation(thisValue);
        String[] rowName = new String[]{"序号", "标签ID", "X坐标", "Y坐标", "Z坐标", "层", "时间"};
        List<Object[]> dataList = objectToArray_historicalLocation(historicalLocationList);
        ExcelUtils excel = new ExcelUtils("轨迹数据", rowName, dataList);
 
        try {
            String fileName = "Excel-" + String.valueOf(System.currentTimeMillis()).substring(4, 13) + ".xls";
            String headStr = "attachment; filename=\"" + fileName + "\"";
            response.setContentType("APPLICATION/OCTET-STREAM");
            response.setHeader("Content-Disposition", headStr);
            OutputStream out = response.getOutputStream();
            excel.export(out);
            out.flush();
            out.close();
        } catch (Exception var14) {
            var14.printStackTrace();
        }
 
        return toPage;
    }
 
    public static List<Object[]> objectToArray_historicalLocation(List<tb_realocation> historicalLocationList) {
        List<Object[]> reList = new ArrayList();
 
        for(int i = 0; i < historicalLocationList.size(); ++i) {
            List<String> words = new ArrayList();
            tb_realocation realocation = (tb_realocation)historicalLocationList.get(i);
            words.add(realocation.getId() + "");
            words.add(realocation.getTagid());
            words.add(realocation.getX());
            words.add(realocation.getY());
            words.add(realocation.getZ());
            words.add(realocation.getLayer());
            words.add(realocation.getTime());
            String[] array = (String[])words.toArray(new String[0]);
            reList.add(array);
        }
 
        return reList;
    }
 
    @RequestMapping(
            value = {"/track_bw_add.do"},
            method = {RequestMethod.POST, RequestMethod.GET}
    )
    public void track_bw_add(HttpServletRequest request) throws IOException {
        String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset());
        tb_track track = (tb_track)JSONObject.toBean(JSONObject.fromObject(jsonString), tb_track.class);
        Date date = new Date(System.currentTimeMillis());
        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
        String currentDate = formatter.format(date);
        this.locationService.track_add(currentDate, track);
    }
 
    @RequestMapping(
            value = {"/tag_time_bw.do"},
            method = {RequestMethod.POST, RequestMethod.GET}
    )
    public void tag_time_bw(HttpServletRequest request) throws IOException {
        String jsonString = RequestUtils.getRequestJsonString(request, Config.getCharset());
        tb_tag tag = (tb_tag)JSONObject.toBean(JSONObject.fromObject(jsonString), tb_tag.class);
        this.locationService.tag_time(tag);
    }
 
    @ResponseBody
    @RequestMapping(
            value = {"panduanweiyi.do"},
            method = {RequestMethod.POST, RequestMethod.GET}
    )
    public String panduanweiyi(HttpServletRequest request) {
        JSONObject json = new JSONObject();
        String name = request.getParameter("name");
        List<String> strs = this.locationService.panduanweiyi(name);
        json.put("dataList", strs);
        return json.toString();
    }
}