fei.wang
2025-04-18 321a74059773cfecc01d6313f7c2e2d45545d6d3
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
package com.hxzkappboot.service.impl;
 
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageInfo;
//import com.hxzk.deo.GpsGuiJi;
//import com.hxzk.mapper.GpsGuiJiDao;
//import com.hxzk.pojo.TbGuiJiTrack;
//import com.hxzk.service.GpsGuiJiService;
import com.hxzkappboot.mapper.GpsGuiJiDao;
import com.hxzkappboot.pojo.GpsGuiJi;
import com.hxzkappboot.pojo.TbGuiJiTrack;
import com.hxzkappboot.service.GpsGuiJiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
 
@Service
public class GpsGuiJiServiceImpl extends ServiceImpl<GpsGuiJiDao, TbGuiJiTrack>implements GpsGuiJiService {
    @Autowired
    GpsGuiJiDao gpsGuiJiDao;
//    @Override
//    public PageInfo<TbGuiJiTrack> findAll(Integer page, Integer limit, String time) {
//        List<TbGuiJiTrack> gps = gpsGuiJiDao.findAll(time);
//        PageInfo<TbGuiJiTrack> info = new PageInfo<>(gps);
//        return info;
//    }
 
    public List<GpsGuiJi> findGuiJi(String tagid, String time2, String time3) throws ParseException {
        SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        SimpleDateFormat outputFormat = new SimpleDateFormat("yyyyMMdd");
        Date date2 = inputFormat.parse(time2);
        Date date3 = inputFormat.parse(time3);
        String formattedTime2 = outputFormat.format(date2);
        String formattedTime3 = outputFormat.format(date3);
        boolean isCrossDay = !formattedTime2.equals(formattedTime3);
        String start;
        if (isCrossDay) {
            start = "SELECT t.tagid, layer, t.baoliu2 AS gspJingdu, t.baoliu3 AS gpsWeidu, t.z AS gpsHaibaGao, t.time AS addtime, t.baoliu1, t.baoliu2, t.baoliu3, t.baoliu4, t.baoliu5, t.baoliu6, t.baoliu7, t.baoliu8 AS name, t.baoliu9 FROM tb_track_" + formattedTime2 + " t WHERE (t.baoliu8 = '" + tagid + "' OR t.tagid = '" + tagid + "') AND t.time >= '" + time2 + "' UNION ALL SELECT t.tagid, layer, t.baoliu2 AS gspJingdu, t.baoliu3 AS gpsWeidu, t.z AS gpsHaibaGao, t.time AS addtime, t.baoliu1, t.baoliu2, t.baoliu3, t.baoliu4, t.baoliu5, t.baoliu6, t.baoliu7, t.baoliu8 AS name, t.baoliu9 FROM tb_track_" + formattedTime3 + " t WHERE (t.baoliu8 = '" + tagid + "' OR t.tagid = '" + tagid + "') AND t.time <= '" + time3 + "'";
        } else {
            start = "SELECT t.tagid, layer, t.baoliu2 AS gspJingdu, t.baoliu3 AS gpsWeidu, t.z AS gpsHaibaGao, t.time AS addtime, t.baoliu1, t.baoliu2, t.baoliu3, t.baoliu4, t.baoliu5, t.baoliu6, t.baoliu7, t.baoliu8 AS name, t.baoliu9 FROM tb_track_" + formattedTime2 + " t WHERE (t.baoliu8 = '" + tagid + "' OR t.tagid = '" + tagid + "') AND t.time >= '" + time2 + "' AND t.time <= '" + time3 + "'";
        }
 
        return this.gpsGuiJiDao.findGpsGuiJi(start, tagid, time2, time3);
    }
 
    public List<GpsGuiJi> findGuiJiFloor(String tagid, String time2, String time3, String layer) throws ParseException {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date now = dateFormat.parse(time2);
        SimpleDateFormat dateFormat2 = new SimpleDateFormat("yyyyMMdd");
        String now2 = dateFormat2.format(now);
        return this.gpsGuiJiDao.findGpsGuiJiFloor(tagid, time2, time3, now2, layer);
    }
}