//package cn.exrick.xboot.your.schedulings;
|
//import cn.exrick.xboot.your.entity.Car;
|
//import cn.exrick.xboot.your.entity.CarLocation;
|
//import cn.exrick.xboot.your.service.*;
|
//import cn.exrick.xboot.your.util.HaiKangPost;
|
//import cn.hutool.core.date.DateUtil;
|
//import cn.hutool.core.util.StrUtil;
|
//import cn.hutool.json.JSONArray;
|
//import cn.hutool.json.JSONObject;
|
//import cn.hutool.json.JSONUtil;
|
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.scheduling.annotation.Scheduled;
|
//import org.springframework.stereotype.Component;
|
//
|
//import java.util.ArrayList;
|
//import java.util.List;
|
//
|
////车辆定位统计
|
//@Component
|
//public class CarLocationScheduleImpl {
|
//
|
// @Autowired
|
// private ICarService iCarService;
|
// @Autowired
|
// private HaiKangPost haiKangPost;
|
// @Autowired
|
// private ICarLocationService iCarLocationService;
|
//
|
// @Scheduled(cron="0 0/10 5,20 * * ? ")//十分钟一次
|
// public void execute(){
|
// List<Car> list = iCarService.list();
|
// List<String> list2 = new ArrayList<>();
|
//
|
// for(int i=0;i<list.size();i++){
|
// if(!StrUtil.isEmpty(list.get(i).getCode())){
|
// list2.add(list.get(i).getCode());
|
// }
|
// }
|
//
|
// String codes[] = new String[list2.size()];
|
// for(int i=0;i<list2.size();i++){
|
// codes[i] = list2.get(i);
|
// }
|
// String latestGps = haiKangPost.findLatestGps(codes);
|
// JSONArray objects = JSONUtil.parseArray(latestGps);
|
// for(int i=0;i<objects.size();i++){
|
// String s = objects.get(i).toString();
|
// JSONObject jsonObject = JSONUtil.parseObj(s);
|
// String time = jsonObject.getStr("time");
|
// String time2 = time.substring(0,10)+" "+time.substring(11,16)+":00";
|
// String carNo = jsonObject.getStr("carNo");
|
// QueryWrapper<CarLocation> wrapper = new QueryWrapper<>();
|
// wrapper.eq("location_time",time2);
|
// wrapper.eq("car_no",carNo);
|
// int count = iCarLocationService.count(wrapper);
|
// if(count>0){
|
// continue;
|
// }
|
// Integer speed = jsonObject.getInt("speed")/10000;
|
// String lng = String.valueOf(jsonObject.getInt("longitude")/360000);
|
// String lat = String.valueOf(jsonObject.getInt("latitude")/360000);
|
// String code = jsonObject.getStr("vehicleIndexCode");
|
// CarLocation obj = new CarLocation();
|
// obj.setCarNo(carNo);
|
// obj.setCode(code);
|
// obj.setLat(lat);
|
// obj.setLng(lng);
|
// obj.setLocationTime(DateUtil.parse(time2,"yyyy-MM-dd HH:mm:ss"));
|
// obj.setSpeed(speed);
|
// iCarLocationService.save(obj);
|
// }
|
// }
|
//}
|