package com.hxzk.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageInfo;
|
import com.hxzk.mapper.GpsTrackDao;
|
import com.hxzk.pojo.TbAchor;
|
import com.hxzk.pojo.TbGpsTrack;
|
import com.hxzk.pojo.TbTag;
|
import com.hxzk.pojo.TbTrackGps;
|
import com.hxzk.service.GpsTrackService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.text.ParseException;
|
import java.text.SimpleDateFormat;
|
import java.time.LocalDate;
|
import java.time.format.DateTimeFormatter;
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
@Service
|
public class GpsTrackServiceImpl extends ServiceImpl<GpsTrackDao, TbGpsTrack> implements GpsTrackService {
|
@Autowired
|
GpsTrackDao gpsTrackDao;
|
|
@Override
|
public PageInfo<TbGpsTrack> findAll(Integer page, Integer limit, String time) {
|
List<TbGpsTrack> gps = gpsTrackDao.findAll(time);
|
PageInfo<TbGpsTrack> info = new PageInfo<>(gps);
|
return info;
|
}
|
|
@Override
|
public List<TbTrackGps> getTagtrack(String tag_id, String begin_time, String end_time, String floor) throws ParseException {
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
Date now = dateFormat.parse(begin_time);
|
SimpleDateFormat dateFormat2 = new SimpleDateFormat("yyyyMMdd");
|
String now2 = dateFormat2.format(now);
|
return gpsTrackDao.getTagtrack(tag_id,begin_time,end_time,floor,now2);
|
}
|
|
@Override
|
public PageInfo<TbGpsTrack> findJingWeiSearch(Integer page, Integer limit, String tagid, String datte) throws ParseException {
|
Integer pages = 0;
|
LocalDate today = LocalDate.now();
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
String formattedDate = today.format(formatter);
|
List<TbGpsTrack> gps = new ArrayList<>();
|
if (datte.equals("") || datte == null){
|
gps = gpsTrackDao.findJingWeiSearch(tagid,formattedDate,pages);
|
}else{
|
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyyMMdd");
|
Date date = inputFormat.parse(datte);
|
String outputDate = outputFormat.format(date);
|
gps = gpsTrackDao.findJingWeiSearch(tagid,outputDate,pages);
|
}
|
PageInfo<TbGpsTrack> info = new PageInfo<>(gps);
|
return info;
|
}
|
|
@Override
|
public List findHourceCount(String dates, String tagid) {
|
// 定义解析的时间格式
|
SimpleDateFormat originalFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
// 定义目标时间格式
|
SimpleDateFormat targetFormat = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat targetFormat1 = new SimpleDateFormat("yyyyMMdd");
|
List Nums = new ArrayList<>();
|
try {
|
// 解析原始时间字符串
|
Date date = originalFormat.parse(dates);
|
// 格式化为目标时间格式
|
String formattedDateStr = targetFormat.format(date);
|
String formattedDateStr1 = targetFormat1.format(date);
|
for (int i = 0 ; i < 24;i++){
|
String num;
|
if (i<10){
|
num=formattedDateStr+" "+"0"+i+":%";
|
}else{
|
num=formattedDateStr+" "+i+":%";
|
}
|
Integer number = 0;
|
if (tagid == ""){
|
number = gpsTrackDao.findCountJw1(num,formattedDateStr1);
|
}else{
|
number = gpsTrackDao.findCountJw(num,formattedDateStr1,tagid);
|
}
|
|
Nums.add(number);
|
}
|
} catch (ParseException e) {
|
e.printStackTrace();
|
}
|
return Nums;
|
}
|
|
@Override
|
public List findHourceCountHaiBa(String dates, String tagid) throws ParseException {
|
// 定义目标时间格式
|
SimpleDateFormat targetFormat = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat targetFormat1 = new SimpleDateFormat("yyyyMMdd");
|
Date date = targetFormat.parse(dates);
|
List Nums = new ArrayList<>();
|
String formattedDateStr = targetFormat.format(date);
|
String formattedDateStr1 = targetFormat1.format(date);
|
for (int i = 0 ; i < 24;i++){
|
String num;
|
if (i<10){
|
num=formattedDateStr+" "+"0"+i+":%";
|
}else{
|
num=formattedDateStr+" "+i+":%";
|
}
|
Double number = gpsTrackDao.findHourceCountHaiBa1(formattedDateStr1,num,tagid);
|
if (number == null){
|
number = (double) 0;
|
}
|
Nums.add(number);
|
}
|
return Nums;
|
}
|
|
|
}
|